首页 > 其他 > 详细

v-resource

时间:2017-08-01 12:04:23      阅读:308      评论:0      收藏:0      [点我收藏+]

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);

 

v-resource

原文:http://www.cnblogs.com/21haoxingxiu/p/7267471.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!