注意区别在于“async ” 及“await ”关键词
同步
async getfiles() {
var result={};
var param = new URLSearchParams()
param.append('id', $("#type").val())
var url = "/backstage/fileupload/getFileName.action";
await axios.post(url, param).then(function (res) {
if (res.status == 200) {
result=res.data.data;
} else {
alert("获取失败!");
}
});
this.filenames=result
},
异步
getfiles() {
var result={};
var param = new URLSearchParams()
param.append('id', $("#type").val())
var url = "/backstage/fileupload/getFileName.action";
axios.post(url, param).then(function (res) {
if (res.status == 200) {
result=res.data.data;
} else {
alert("获取失败!");
}
});
this.filenames=result
},