I worked on it all afternoon and reinstalled it many times. I found that there was no dev-server.js file in the build folder of vue-cli.

clipboard.png
compared with online tutorials, there are two fewer files and one more picture. And a small number of dev-server.js files happen to simulate the background data, how to change now, how to simulate the local data operation?

Mar.04,2021

the answer is the same as the one on the first floor:
in the webpack.dev.conf.js file

//
const express = require('express')
const app = express()
var appData = require('../data.json')
var seller = appData.seller
var goods = appData.goods
var ratings = appData.ratings
var apiRoutes = express.Router()
app.use('/api', apiRoutes)

//devServer,
before(app) {
  app.get('/api/seller', (req, res) => {
    res.json({
      // json
      errno: 0,
      data: seller
    })
  }),
  app.get('/api/goods', (req, res) => {
    res.json({
      // json
      errno: 0,
      data: goods
    })
  }),
  app.get('/api/ratings', (req, res) => {
    res.json({
      // json
      errno: 0,
      data: ratings
    })
  })
}

that's fine


edit in the webpack.dev.conf.js file.

add the following to the devServer option

  manually build a single vue+node page (1)  

Menu