Vue.js 引入外部js方法


1、外部文件config.js

第一種寫法

 1 //常量的定義
 2 
 3 const config = {
 4   baseurl:'http://172.16.114.5:8088/MGT2'
 5 }
 6 
 7 //函數的定義
 8 
 9 function formatXml(text) {
10   return text
11 }
12 
13 //導出 {常量名、函數名}
14 export {config,formatXml}

第二種寫法

 1 //常量的定義
 2 
 3 export const config = {
 4   baseurl:'http://172.16.114.5:8088/MGT2'
 5 }
 6 
 7 //函數的定義
 8 
 9 export function formatXml(text) {
10   return text
11 }

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

  import {config,formatXml} from '../config'//記得帶上{}花括號

轉至:https://www.cnblogs.com/qiu-Ann/p/7463484.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM