1 回答

TA贡献1847条经验 获得超11个赞
new Vue({
el:'#box',
data:function() {
return {
rel: ""
}
},
methods:{
gets1:function(num){
console.log(num);
// 把this赋值给self变量
var self = this;
this.$http.get('php/get.php').then(function(rel){
console.log(rel);
/* 这个里面的this指向的不是Vue实例
* 非严格模式下是Window对象,所以使用this.rel不起作用
* 所以在外层先把this赋值给self变量
*/
// this.rel = rel;
self.rel = rel;
},function(err){
})
},
}
})
添加回答
举报