1.webpack中接口调用方式第一种webpack.dev.config.js2. 第二种2. build打包启动1. 执行npm run build打包使用了vue-router路由懒加载,所以app.js只有50KB2. 启动本地服务在项目文件夹下,新建prod.server.js,然后node prod.server.jsvar express = require(’express’)var config = require(’./config/index’)var axios = require(‘axios’)var app = express()var port = process.env.PORT || config.build.portvar apiRoutes = express.Router()apiRoutes.get(’/getDiscList’,function(req, res){ console.log(‘1111111’) var url = ‘https://c.y.qq.com/splcloud/fcgi-bin/fcg_get_diss_by_tag.fcg' axios.get(url, { headers: { referer: ‘https://c.y.qq.com’, host: ‘c.y.qq.com’ }, params: req.query }).then((response) => { res.json(response.data) }).catch((e) => { console.log(e) })})apiRoutes.get(’/lyric’,function(req, res){ console.log(‘222222’) var url = ‘https://szc.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg' axios.get(url, { headers: { referer: ‘https://c.y.qq.com’, host: ‘c.y.qq.com’ }, params: req.query }).then((response) => { res.json(response) }).catch((e) => { console.log(e) })})apiRoutes.get(’/getSongList’,function(req, res){ console.log(‘33333333’) var url = ‘https://c.y.qq.com/qzone/fcg-bin/fcg_ucc_getcdinfo_byids_cp.fcg' axios.get(url, { headers: { referer: ‘https://y.qq.com/', host: ‘c.y.qq.com’ }, params: req.query }).then((response) => { res.json(response) }).catch((e) => { console.log(e) })})apiRoutes.get(’/getHotKey’,function(req, res){ console.log(‘444444’) var url = ‘https://c.y.qq.com/splcloud/fcgi-bin/gethotkey.fcg' axios.get(url, { headers: { referer: ‘https://y.qq.com/', host: ‘c.y.qq.com’ }, params: req.query }).then((response) => { res.json(response.data) }).catch((e) => { console.log(e) })})apiRoutes.get(’/search’,function(req, res){ console.log(‘55555’) var url = ‘https://c.y.qq.com/soso/fcgi-bin/search_for_qq_cp' axios.get(url, { headers: { referer: ‘https://y.qq.com/', host: ‘c.y.qq.com’ }, params: req.query }).then((response) => { res.json(response.data) }).catch((e) => { console.log(e) })})app.use(’/api’, apiRoutes)app.use(express.static(’./dist’))module.exports = app.listen(port, function(err) { if(err) { console.log(err) return } console.log(’listening at http://localhost:’ + port + ‘\n’)})