标签:tde clist ble raw block == big evel ast
一、引包
const axios = require(‘axios‘);const express = require(‘express‘);const apiRoutes = express.Router();
const devWebpackConfig = merge(baseWebpackConfig, {module: {rules: utils.styleLoaders({sourceMap: config.dev.cssSourceMap, usePostCSS: true})},// cheap-module-eval-source-map is faster for developmentdevtool: config.dev.devtool,// these devServer options should be customized in /config/index.jsdevServer:{//在这里添加一个before方法before(apiRoutes){apiRoutes.get(‘/api/getDiscList‘,(req,res)=>{const url = ‘这里是要链接的api地址‘;axios.get(url, {headers: {referer: ‘配置api地址referer‘,host: ‘配置api地址host‘},params: req.query //这是请求的query}).then((response) =>{//response是api地址返回的,数据在data里。res.json(response.data)}).catch((e) =>{console.log(e);})});// app.use(‘/api‘, apiRoutes);}}源博客连接:http://www.cnblogs.com/langzianan/p/7989572.html
标签:tde clist ble raw block == big evel ast
原文地址:http://www.cnblogs.com/kusideshu/p/7989622.html