Mock data in build/dev-server.js
/数据mock
var appData = require('../data.json');
var seller = appData.seller;
var goods = appData.goods;
var ratings = appData.ratings;
var apiRouters = express.Router();
apiRouters.get('/seller',function(req,res){
res.json({
errno:0,
data:seller
})
})
apiRouters.get('/goods',function(req,res){
res.json({
errno:0,
data:goods
})
})
apiRouters.get('/ratings',function(req,res){
res.json({
errno:0,
data:ratings
})
})
app.use('/api',apiRouters)
//数据mock
The api you use should use a relative path, so you need to open the http service and start the project after dist. You may use ./ or /, and then open the file directly, and the path will be read as the path of your computer's hard disk.
The error message is cross-domain