Open Webpack.dev.conf.js
Add the following configuration after const Portfinder = require (' Portfinder ')
1Const EXPRESS = require (' Express ')2Const APP = Express ()//Request Server3 varAppData = require ('.. /data.json ')//loading Local Data4 varSeller = Appdata.seller//get the corresponding data5 varGoods =Appdata.goods6 varRatings =appdata.ratings7 varApiroutes =Express. Router ()8App.use ('/api ', apiroutes)//request data by routing
Add the following configuration in Devserver: {}
1 before (app) {2App.get ('/api/seller ', (req, res) = {3 Res.json ({4errno:0,5Data:seller//interface returns JSON data6 })7 }),8App.get ('/api/goods ', (req, res) = {9 Res.json ({Tenerrno:0, OneData:goods//interface returns JSON data A }) - }), -App.get ('/api/ratings ', (req, res) = { the Res.json ({ -errno:0, -Data:ratings//interface returns JSON data - }) + }) - } +}
vue2.0 configuring Webpack.dev.conf.js to load local JSON data