版本:
"name": "vue-element-admin",
"version": "4.4.0",
原因:main.js中使用了mock数据,
以及vue.config.js中//before: require('./mock/mock-server.js')//**注释掉这一行
注释掉即可解决
注释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()
// }
注释vue.config.js中以下内容
publicPath: './',
outputDir: 'dist',
assetsDir: 'static',
lintOnSave: process.env.NODE_ENV === 'development',
productionSourceMap: false,
devServer: {
port: port,
open: true,
overlay: {
warnings: false,
errors: true
}//,
//before: require('./mock/mock-server.js')//**注释掉这一行
},
本文介绍如何解决Vue项目中因使用mock数据导致的问题,包括注释main.js和vue.config.js中的特定代码行,以确保线上环境中不会加载mock数据。
6224

被折叠的 条评论
为什么被折叠?



