vue引入js函數


1、外部文件config.js

第一種寫法

//常量的定義

const config = {
  baseurl:'http://172.16.114.5:8088/MGT2'
}

//函數的定義

function formatXml(text) {
  return text
}

function getjs1() {
    return "11223344"
  }

//導出 {常量名、函數名}
export {config1,formatXml,getjs1}

第二種寫法

//常量的定義

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'//記得帶上{}花括號 
 import {getjs1} from "./config"
 

3、調用

 getjs1()


免責聲明!

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



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