The data returned by axios call API is assigned to options, and an error is reported TypeError: Cannot set property 'options' of undefined
axios.get('/api/ServerInfo/GetQueryTypedTSSST' ).then(function(res){ this.options=res.data }).catch(function (error) { console.log(error); });
But already declared in the component
data() { return { options:[],
In the then
interior can not be instantiated using the Vue this
, because the inside this
is not bound.
You can use ES6 arrow functions
axios.get('/api/ServerInfo/GetQueryTypedTSSST' ).then((res)=>{ this.options=res.data }).catch(function (error) { console.log(error); });
Or define that outside of axios
var that=this axios.get('/api/ServerInfo/GetQueryTypedTSSST' ).then(function(res){ this.options=res.data }).catch(function (error) { console.log(error); });