使用网址:http://localhost:9098/axios 测试:mocker-api 的使用,步骤:
- 安装 mocker-api:
npm install mocker-api --save-dev
- package.json 文件中配置:
"mocker": "cross-env NO_PROXY=false node build/dev-server.js",
- 文件:build/dev-server.js 中,添加代码:
const apiMocker = require('mocker-api');
及apiMocker(app, path.resolve('./mocker/index.js'))
- 书写
mocker/index.js
- 运行:
npm run mocker
- 访问:http://localhost:9098/axios ,返回数据会是:mocker/index.js 中定义返回的内容。
- 一篇介绍文章:https://juejin.im/post/5afba2746fb9a07aaf356327
el-tabs 里面是嵌套路由,第一个tab下的路由,离开时提示"是否要离开当前页面",路由网址:http://localhost:9098/tabs/tabFirst ,实现点:
- 跳到第二个tab下面的路由,也要提示
- 用户刷新页面时,tab 样式在正确的位置上
- 注意:用到了 el-tabs 的 before-leave 属性,element-ui 版本 2.4.11 才支持。
博客页面:https://www.cnblogs.com/cag2050/p/9293949.html
- webpack打包时,设置一个唯一的打包字符串(比如:当前时间戳),存到一个文件里(最好是json文件,此文件不缓存);
- 将打包字符串存在 localStorage 中;
- 进入每个路由时,比较 localStorage 中的打包字符串与文件中新的打包字符串是否一致。不一致的话,刷新页面。
- 将新的打包字符串,存入 localStorage。
- 新增动态表单(select和input)
- components文件夹中添加组件vue;
- router/index.js中导入组件、添加路由;
- App.vue添加router-link。
- .editorconfig 修改:indent_size = 4;
- .eslintrc.js 规则rules中添加一行:'indent': [2, 4, { "SwitchCase": 1 }];
- build/webpack.base.config.js 在eslint-loader配置部分,在语句:include: [resolve('src/components'), resolve('test')] 中配置需要校验的目录
A Vue.js project
# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production with minification
npm run build
# build for production and view the bundle analyzer report
npm run build --report
For detailed explanation on how things work, checkout the guide and docs for vue-loader.