问题描述
如图就死活拿不到数据了,不知道怎么回事求大神解救一下
问题出现的环境背景及自己尝试过哪些方法
相关代码
// 请把代码文本粘贴到下方(请勿用图片代替代码)
new Vue({
el: '#a-weather-waring',
data: {
weatherWaring:null,
v_time_from2: null,
v_time_toto2: null
},
methods: {
Get_YJweather: function() {
this.v_time_from2 = this.$refs.v_time_from.value;
this.v_time_toto2 = this.$refs.v_time_toto.value;
mui.ajax('http://lbzhywpt.portdalian.com:999/WeatherHandler.ashx?method=Get_YJweather', {
data: {
timefrom: this.v_time_from2,
timeto: this.v_time_toto2
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
success: function(result) {
console.log(result);
this.weatherWaring = result;
console.log(weatherWaring);
},
error: function(xhr, type, errorThrown) {}
});
},
}
});
this.weatherWaring = result;
你这里的this指向的是mui所以赋值失败;