类型“{ searchWeather: () => void; }”上不存在属性“weatherList”。ts(2339) #Vue #axios

怎么解决, 提示在定义的Vue axios方法的回调函数内部调用不到定义的属性weatherList

const app = new Vue({
    el: "#app",
    data: {
        city: '',
        weatherList: [],
    },
    methods: {
        searchWeather: function () {
            //保存this
            const that = this;
            //调用接口
            axios.get('http://wthrcdn.etouch.cn/weather_mini?city=' + this.city)
                .then(function (response) {
                    that.weatherList = response.data.data.forecast;
                })
                .catch(function (err) { console.log(err); }
                )
        }
    },
})

你应该写成app啊。。const that = app;

哦哦哦, 果然修改之后就好了, 谢谢