This article mainly introduces the code analysis of vue simulation background data, which has a certain reference value. Now I share it with everyone. Friends in need can refer to it
In the project The root directory stores the json file
Create a server.js file in the project root directory
var express = require("express"); var app = express(); var appData = require('./data.json'); var seller = appData.seller; var goods = appData.goods; var ratings = appData.ratings; var apiRoutes = express.Router(); apiRoutes.get('/seller', function (req, res) { res.json({ errno: 0, data: seller }); }); apiRoutes.get('/goods', function (req, res) { res.json({ errno: 0, data: goods }); }); apiRoutes.get('/ratings', function (req, res) { res.json({ errno: 0, data: ratings }); }); app.use('/api', apiRoutes); app.listen(8081); console.log("server run at port :8081");
Access link:
http://localhost:8080/
http://localhost:8081/api/*
Recommended chrome plug-in:
jsonview
vue-devtools
Related Recommended:
How to use sweetalert2 pop-up plug-in in vue project
Implementation of mobile web music player based on vue
The above is the detailed content of Code analysis on vue simulation background data. For more information, please follow other related articles on the PHP Chinese website!