提交 122546b5 编写于 作者: 杜庆泉's avatar 杜庆泉

toast 示例完善

上级 a011c05b
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<view class="uni-padding-wrap"> <view class="uni-padding-wrap">
<view class="uni-btn-v"> <view class="uni-btn-v">
<button class="uni-btn" type="default" @tap="toast1Tap">点击弹出默认toast</button> <button class="uni-btn" type="default" @tap="toast1Tap">点击弹出默认toast</button>
<button class="uni-btn" type="default" @tap="toastTapIconError">点击弹出设置icon的toast</button>
<button class="uni-btn" type="default" @tap="toast2Tap">点击弹出设置duration的toast</button> <button class="uni-btn" type="default" @tap="toast2Tap">点击弹出设置duration的toast</button>
<button class="uni-btn" type="default" @tap="toast3Tap">点击弹出显示loading的toast</button> <button class="uni-btn" type="default" @tap="toast3Tap">点击弹出显示loading的toast</button>
<!-- #ifndef MP-ALIPAY --> <!-- #ifndef MP-ALIPAY -->
...@@ -14,6 +15,7 @@ ...@@ -14,6 +15,7 @@
<!-- #endif --> <!-- #endif -->
<button class="uni-btn" type="default" @tap="hideToast">点击隐藏toast</button> <button class="uni-btn" type="default" @tap="hideToast">点击隐藏toast</button>
</view> </view>
<text>{{exeRet}}</text>
</view> </view>
</view> </view>
</template> </template>
...@@ -22,6 +24,7 @@ ...@@ -22,6 +24,7 @@
data() { data() {
return { return {
title: 'toast', title: 'toast',
exeRet:'',
_showTimer: 0 _showTimer: 0
} }
}, },
...@@ -33,20 +36,50 @@ ...@@ -33,20 +36,50 @@
methods: { methods: {
toast1Tap: function () { toast1Tap: function () {
uni.showToast({ uni.showToast({
title: "默认" title: "默认",
success:function(res){
this.exeRet = "success:" + JSON.stringify(res) + new Date()
},
fail:function(res){
this.exeRet = "fail:" + JSON.stringify(res)
},
})
},
toastTapIconError: function () {
uni.showToast({
title: "默认",
icon:'error',
success:function(res){
this.exeRet = "success:" + JSON.stringify(res) + new Date()
},
fail:function(res){
this.exeRet = "fail:" + JSON.stringify(res)
},
}) })
}, },
toast2Tap: function () { toast2Tap: function () {
uni.showToast({ uni.showToast({
title: "duration 3000", title: "duration 3000",
duration: 3000 duration: 3000,
success:function(res){
this.exeRet = "success:" + JSON.stringify(res) + new Date()
},
fail:function(res){
this.exeRet = "fail:" + JSON.stringify(res)
},
}) })
}, },
toast3Tap: function () { toast3Tap: function () {
uni.showToast({ uni.showToast({
title: "loading", title: "loading",
icon: "loading", icon: "loading",
duration: 5000 duration: 5000,
success:function(res){
this.exeRet = "success:" + JSON.stringify(res) + new Date()
},
fail:function(res){
this.exeRet = "fail:" + JSON.stringify(res)
},
}) })
// #ifdef MP-ALIPAY // #ifdef MP-ALIPAY
this._showTimer = setTimeout(() => { this._showTimer = setTimeout(() => {
...@@ -61,14 +94,26 @@ ...@@ -61,14 +94,26 @@
toast4Tap: function () { toast4Tap: function () {
uni.showToast({ uni.showToast({
title: "logo", title: "logo",
image: "/static/uni.png" image: "/static/uni.png",
success:function(res){
this.exeRet = "success:" + JSON.stringify(res) + new Date()
},
fail:function(res){
this.exeRet = "fail:" + JSON.stringify(res)
},
}) })
}, },
// #ifdef APP-PLUS // #ifdef APP-PLUS
toast5Tap: function () { toast5Tap: function () {
uni.showToast({ uni.showToast({
title: "显示一段轻提示", title: "显示一段轻提示",
position: 'bottom' position: 'bottom',
success:function(res){
this.exeRet = "success:" + JSON.stringify(res) + new Date()
},
fail:function(res){
this.exeRet = "fail:" + JSON.stringify(res)
},
}) })
}, },
// #endif // #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册