Home >Web Front-end >Vue.js >How to introduce external js in vue.js
How to introduce external js into vue.js: 1. Add code [function formatXml(text){return text}] in the external file [config.js]; 2. Use the import statement to introduce [config.js 】The constants and methods inside are enough.
The operating environment of this tutorial: Windows 7 system, Vue version 2.9.6, Dell G3 computer. This method is suitable for all brands of computers.
[Related free article recommendations: vue.js]
vue.js method of introducing external js:
1. External file config.js
First way of writing
//常量的定义 const config = { baseurl:‘http://172.16.114.5:8088/MGT2‘ } //函数的定义 function formatXml(text) { return text } //导出 {常量名、函数名} export {config,formatXml}
Second way of writing
//常量的定义 export const config = { baseurl:‘http://172.16.114.5:8088/MGT2‘ } //函数的定义 export function formatXml(text) { return text }
2.Introduction of config Constants and methods in .js
import {config,formatXml} from ‘../config‘//记得带上{}花括号
Related free learning recommendations: javascript (video)
The above is the detailed content of How to introduce external js in vue.js. For more information, please follow other related articles on the PHP Chinese website!