vue.js引入外部js的方法:1、使用外部文件【config.js】,代碼為【function formatXml(text){return text}】;2、引入【config.js】里面的常量和方法。
本教程操作環(huán)境:windows7系統(tǒng)、Vue2.9.6版,該方法適用于所有品牌電腦。
【相關(guān)免費(fèi)文章推薦:vue.js】
vue.js引入外部js的方法:
1、外部文件config.js
第一種寫法
//常量的定義 const config = { baseurl:‘http://172.16.114.5:8088/MGT2‘ } //函數(shù)的定義 function formatXml(text) { return text } //導(dǎo)出 {常量名、函數(shù)名} export {config,formatXml}
第二種寫法
//常量的定義 export const config = { baseurl:‘http://172.16.114.5:8088/MGT2‘ } //函數(shù)的定義 export function formatXml(text) { return text }
2、引入config.js里面的常量和方法
import {config,formatXml} from ‘../config‘//記得帶上{}花括號
相關(guān)免費(fèi)學(xué)習(xí)推薦:javascript(視頻)