首页 > 其他 > 详细

vue-resource的使用,前后端数据交互

时间:2018-10-27 19:15:20      阅读:156      评论:0      收藏:0      [点我收藏+]

vue-resource的使用,前后端数据交互

1:导入vue与vue-resource的js

技术分享图片

 js下载:   https://pan.baidu.com/s/1fs5QaNwcl2AMEyp_kUgFyQ

 

注意如果是springBoot项目需要在配置文件中排除静态文件的拦截:

技术分享图片

 

 

 post方法:

 new Vue({
       el:"#app",
        data:{
            tableMsg:"vue+html+bootstrap",
            userList:[]
        },
       methods:{

       },
       created: function() {
           this.$http.post(
               //请求路由:
               ‘http://localhost:8080/user/data‘,
               {
               //传递的参数:
                   currentPage:1,
                   pageSize:3
                   // userName:"wuji"

           }, {
               headers: {
               },
               emulateJSON: true
           }).then((response) => {
               //响应成功回调
               this.userList = response.data.list;
       }).catch(function(response) {
           //失败回调:
               console.log(response);
           });
       }
   })

 

vue-resource的使用,前后端数据交互

原文:https://www.cnblogs.com/dw3306/p/9862634.html

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