1,主页使用 app.vue
data() {
return {
seller:{}
}
},
created() {
this.$http.get('/api/seller').then((response) => {
response = response.body;
if(response.errno===ERR_Ok){
this.seller = response.data;
console.log(this.seller);
}
});
},
created() {
this.$http.get('/api/seller').then((response) => {
response = response.body;
if(response.errno===ERR_Ok){
this.seller = response.data;
console.log(this.seller);
}
});
},
2,devserver.js 设置
var app = express()
var appData = require('../data.json');
var seller = appData.seller;
var goods = appData.goods;
var ratings = appData.ratings;
var apiRoutes = express.Router();
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
});
});
app.use('/api', apiRoutes);