_request() {
uni.request({
url: this.websiteUrl + `${stringListApi}`,
method: 'POST',
dataType: 'json',
data: {},
success: res => {
this.stringList = res.data.data;
console.log(this.stringList);
},
fail: err => {
console.log(err);
},
complete: () => {}
});
},
_requestPromise() {
uni.request({
url: this.websiteUrl + `${stringListApi}`,
method: 'POST',
dataType: 'json',
data: { token: this.$store.state.token }
})
.then(res => {
this.stringList = res[1].data.data;
console.log(this.stringList);
})
.catch(err => {
console.log(err);
});
},
async _requestAwait() {
const [err, res] = await uni.request({
url: this.websiteUrl + `${stringListApi}`,
method: 'POST',
dataType: 'json',
data: {}
});
if (err) {
console.log(err);
} else {
this.stringList = res.data.data;
console.log(this.stringList);
}
}
uniapp三种请求方法示例
最新推荐文章于 2024-04-23 12:36:54 发布