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()
posted @ 2022-03-09 12:39  寒冷的雨呢  阅读(1511)  评论(0编辑  收藏  举报