提交 43085e7a 编写于 作者: taohebin@dcloud.io's avatar taohebin@dcloud.io

fix: 修改request的loading

上级 509d1fb2
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<textarea :value="res"></textarea> <textarea :value="res"></textarea>
</view> </view>
<view class="uni-btn-v uni-common-mt"> <view class="uni-btn-v uni-common-mt">
<button type="primary" @click="sendRequest" :loading="loading">发起请求(Callback)</button> <button type="primary" @click="sendRequest">发起请求(Callback)</button>
</view> </view>
</view> </view>
</view> </view>
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
data() { data() {
return { return {
title: 'request', title: 'request',
loading: false,
res: '', res: '',
task: null as RequestTask | null, task: null as RequestTask | null,
pageVisible: false pageVisible: false
...@@ -37,7 +36,9 @@ ...@@ -37,7 +36,9 @@
}, },
methods: { methods: {
sendRequest() { sendRequest() {
this.loading = true; uni.showLoading({
title:"请求中..."
})
this.task = uni.request({ this.task = uni.request({
url: "https://unidemo.dcloud.net.cn/ajax/echo/text?name=uni-app", url: "https://unidemo.dcloud.net.cn/ajax/echo/text?name=uni-app",
dataType: "json", dataType: "json",
...@@ -75,7 +76,7 @@ ...@@ -75,7 +76,7 @@
} }
}, },
complete() { complete() {
this.loading = false; uni.hideLoading()
}, },
}); });
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册