站长资讯网
最全最丰富的资讯网站

vue.js怎么引入外部js

vue.js引入外部js的方法:1、使用外部文件【config.js】,代码为【function formatXml(text){return text}】;2、引入【config.js】里面的常量和方法。

vue.js怎么引入外部js

本教程操作环境:windows7系统、Vue2.9.6版,该方法适用于所有品牌电脑。

【相关免费文章推荐:vue.js】

vue.js引入外部js的方法:

1、外部文件config.js

第一种写法

//常量的定义   const config = {  baseurl:‘http://172.16.114.5:8088/MGT2‘  } //函数的定义 function formatXml(text) {   return text  } //导出 {常量名、函数名} export {config,formatXml}

第二种写法

//常量的定义 export const config = {    baseurl:‘http://172.16.114.5:8088/MGT2‘ }  //函数的定义    export function formatXml(text) {  return text }

2、引入config.js里面的常量和方法

  import {config,formatXml} from ‘../config‘//记得带上{}花括号

相关免费学习推荐:javascript(视频)

赞(0)
分享到: 更多 (0)