Vue.js 引入外部js方法

烂漫一生 提交于 2020-01-27 13:09:04

 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'//记得带上{}花括号

 

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!