参考文章一:文章地址
async getScheduleList(selectDate) {
let response;
// 这里request为向服务的发请求的方法
await request(api.getScheduleList, {
date: selectDate
}).then(res => {
response = res;
});
return response
}
init() {
this.getScheduleList(selectDate).then(res => {
console.log(res)
})
}
参考文章二:文章地址
data() {
return {
topicList: []
}
},
async created() {
await this.getTopicList()
console.log(this.topicList)
},
methods: {
async getTopicList() {
let resp = await axios.get(`/topic`)
if (resp.data.status === 1) {
this.topicList = resp.data.data.data
}
}
}