当前位置:   article > 正文

Vue.js - 引入外部 JS 文件_vue.config.js 引入js

vue.config.js 引入js

一、外部文件 config.js

第一种写法:

  1. // 常量的定义
  2. const config = {
  3. baseurl:'http://172.16.114.5:8088/MGT2'
  4. }
  5. // 函数的定义
  6. function formatXml(text) {
  7.   return text
  8. }
  9. // 导出 {常量名、函数名}
  10. export {config,formatXml}

第二种写法:

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

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

import {config,formatXml} from '../config' // 记得带上{}花括号

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/86178
推荐阅读
相关标签
  

闽ICP备14008679号