vue学习第一天(取消mock,连接服务端)
克隆项目打开vue.config.js//注释devServer下的before// before: require('./mock/mock-server.js')devServer: {port: port,open: true,overlay: {warnings: false,errors: true}// before: require('./mock/mock-server.js').
·
2021-4-9更
clone的vue-admin-template,下载下来后,直接更改==.env.development内的VUE_APP_BASE_API = 'http://127.0.0.1:7001’==就可调用其他接口
- 克隆项目
- 打开vue.config.js
//注释devServer下的before
// before: require('./mock/mock-server.js')
devServer: {
port: port,
open: true,
overlay: {
warnings: false,
errors: true
}
// before: require('./mock/mock-server.js')
}
- 打开==/src/main.js==
//注释===记得有事没事看看英文
/**
* If you don't want to use mock-server
* you want to use MockJs for mock api
* you can execute: mockXHR()
*
* Currently MockJs will be used in the production environment,
* please remove it before going online ! ! !
*/
// if (process.env.NODE_ENV === 'production') {
// const { mockXHR } = require('../mock')
// mockXHR()
// }
- 打开==.env.development==
//编辑# base api
//例如我的服务端是在本地,地址为http://localhost:12001
# just a flag
ENV = 'development'
# base api
VUE_APP_BASE_API = 'http://localhost:12001'
- 最后一步,重启项目,end~~
更多推荐
已为社区贡献1条内容
所有评论(0)