The nodeJS + Express environment is set up by default.

Create a JSON file on the local disk, nodeJS reads the CONTENT of the JSON file, and the front-end obtains the content through the interface and displays it on the page.

What needs to be done in the nodeJS project:

1. Create the test.js file in the Routes folder.

var express = require('express'); var router = express.Router(); var fs = require('fs'); /* GET users listing. */router.get('/', function (req, res, next) { let file = 'D:\\myJob\\nodeJob\\testJson.json'; Fs. readFile(file, 'utf-8', function (err, data) {if (err) {res.send(' failed to readFile '); } else { res.send(data); }}); }); module.exports = router;Copy the code

As shown in figure:

2. Add two lines of code to the app.js file, as shown in the figure below

3. Run the NPM start command in CMD

What needs to be done in the VUE front-end project

1. Because the ports are different, perform cross-domain configuration based on VUE-CLI3, as shown in the figure

2. Invoke the interface on the corresponding page

3. View the final page display

OK, complete a test.