getCommonItem(value) {
return api.commonItem({value: value}).then(res => {
this.name = res.data.name
})
},
<span>{{name}}</span>
there is no need to nest another layer.
getCommonItem(value) {
// api.commonItem
return api.commonItem({value: value})
},
the getCommonItem method you write returns a promise object. So what is displayed on the interface is an object
promise can only pass values, but cannot return values
commonItem written by yourself do not return Promise
if you want to make minimal changes, you'd better use async await
to visually observe this one.
haven't tried whether this is feasible, you can try
async getCommonItem(value) {
// api.commonItem
return await api.commonItem({value: value}).then(res => {
console.log("",res.data.name)
return Promise.resolve(res.data.name)
})
}