vue配置请求本地json数据需要哪些步骤
展开全部
在const app = express()后,const compiler = webpack(webpackConfig)前配置即可,
var appData = require('../data.json')
var seller = appData.seller
var goods = appData.goods
var ratings = appData.ratings
var foods = appData.foods
var pice = appData.pice
var apiRoutes = express.Router()
apiRoutes.post('/foods', function (req, res) {
res.json({
errno: 0,
data: foods
});
})
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
});
})
apiRoutes.get('/pice', function (req, res) {
res.json({
errno: 0,
data: pice
});
})
app.use('/api',apiRoutes)
var appData = require('../data.json')
var seller = appData.seller
var goods = appData.goods
var ratings = appData.ratings
var foods = appData.foods
var pice = appData.pice
var apiRoutes = express.Router()
apiRoutes.post('/foods', function (req, res) {
res.json({
errno: 0,
data: foods
});
})
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
});
})
apiRoutes.get('/pice', function (req, res) {
res.json({
errno: 0,
data: pice
});
})
app.use('/api',apiRoutes)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询