How to use webpack vue to develop with express

  node.js, question

I now initialize the project through vue-cli, and put the background related codes under the server folder under the root directory. The webpack starts the local server in World Wide Web Publishing Service, and express under the server starts the server with 3000 ports.
At present, I can obtain express’s response by initiating get request at the front desk in the following ways, probably initiating and receiving Qing Dynasty as follows.

export default {
 data () {
 return {
 a: 'aaaaaaa'
 bracket
 },
 components: {
 Hello
 },
 created: function () {
 this.$http.get('http://localhost:3000/api/test').then(function (data) {
 console.log(data)
 })
 bracket
 bracket
var express = require('express');
 
 var app = express();
 
 var api = require('./routes/api');
 
 //Cross-domain support
 app.all('*', (req, res, next) => {
 const origin = req.headers.origin;
 res.header('Access-Control-Allow-Origin', origin);
 res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, token');
 res.header('Access-Control-Allow-Credentials', true);
 res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, OPTIONS, DELETE');
 
 next();
 });
 
 app.use('/api', api);
 
 app.listen(3000);
var express = require('express');
 
 var router = express.Router();
 
 router.get('/test', function (req, res, next) {
 res.send({msg: 'success'});
 })
 
 module.exports = router;

Then the value of msg exists under response.body
Now I have two choices, because I want to be a community for graduation design, then use
Vue-router or express is better for routing?
The vue-router is used to access the page through localhost:8080. The background is used to render the page by returning json data and the foreground vue obtains it?
Using express route is to access the page through localhost:3000, send static files directly in the background, or can vue components be used in ejs template engine?

That’s because vue-cli already has express, and cli itself is a one-stop environment. You can look at package.json, which already contains express

I haven’t used express.Router () before, so I went to the official website. You try inrouter.get()Add after the codeapp.use(router)Try it.

router.get('/test', function (req, res, next) {
 res.send('test');
 })
 
 app.use(router);
 
 app.listen(3000);

Router () link:http://expressjs.com/zh-cn/4x …