Vue打包后,如果想修改统一链接路径的方案。
第一步:
┌── build
├── config
├── node_modules
├── src
├── static
│ ├── config.js // 配置文件
│
├── index.html:
这里说明下,赋值给window,在vue里面获取不到window对象。所以不要赋值给window,直接定义个常量就好。
第二步:
const $gloableConfig = {
"baseUrl": "xxxxxxx", //集成接口路径
"ProjectName": "xxxxxxx",
};
第三步:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>测试</title>
<script src="./static/config.js"></script>
</head>
<body>
<div id="app"></div>
</body>
</html>
注:引入的文件路径一定要正确哦
vue里面的源文件就可以随便引用:
baseUrl = $gloableConfig.baseUrl
然后就可以了。。。。。。