Home > Web Front-end > JS Tutorial > Code analysis on vue simulation background data

Code analysis on vue simulation background data

不言
Release: 2018-07-17 10:42:13
Original
1232 people have browsed it

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

  1. In the project The root directory stores the json file

  2. 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");
Copy after login

Be careful not to conflict with the port number and the json file Path

After the file is created, operate the command in the command box as shown below. Enter the link in the browser to access the json data

Code analysis on vue simulation background data

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template