ajax给data赋值,vue 2.0 methods 里ajax生成的数据,怎么赋值给data

  • Post author:
  • Post category:vue


  • {

    {pro.price}}
  • {

    {pro.num}}

var vm = new Vue({

el:’#all’,

data:{

detail:[

{name:’五档’,id:’0′,iscur:true},

{name:’单价’,id:’1′,iscur:false},

{name:’数量’,id:’2′,iscur:false},

{name:’总价’,id:’3′,iscur:false},

],

info:{},

},

methods:{

datas: function (type,ext){

$.ajax({

type:”GET”,

url:”/trade_data”,

data:{type:type,ext:ext},

datatype:”json”,

success: function(reslue){

this.info = resule;

}.bind(this)

})

}

}

})

怎么调用显示在页面?ul li 里面显示

***已解决***:

var vm = new Vue({

el:’#all’,

data:{

detail:[

{name:’五档’,id:’0′,iscur:true},

{name:’单价’,id:’1′,iscur:false},

{name:’数量’,id:’2′,iscur:false},

{name:’总价’,id:’3′,iscur:false},

],

info_in:[],

info_out:[]

},

mounted: function () {

var that = this;

$.ajax({

type:”GET”,

url:”/trade_data”,

data:{type:$_GET[‘type’],ext:$_GET[‘ext’]},

dataType:”json”,

success: function(result) {

that.info_in=result.in;

that.info_out=result.out;

}

})

}

})

感谢各位回答