11<template >
22 <demo-section >
33 <demo-block :title =" $t('title1')" >
4- <van-button
5- type =" primary"
6- @click =" $toast($t('text'))"
7- >
8- {{ $t('title1') }}
9- </van-button >
10- <van-button
11- type =" primary"
12- @click =" $toast($t('longText'))"
13- >
14- {{ $t('longTextButton') }}
15- </van-button >
4+ <van-button type =" primary" :text =" $t('title1')" @click =" $toast($t('text'))" />
5+ <van-button type =" primary" :text =" $t('longTextButton')" @click =" $toast($t('longText'))" />
166 </demo-block >
177
188 <demo-block :title =" $t('title2')" >
19- <van-button
20- type =" primary"
21- @click =" showLoadingToast"
22- >
23- {{ $t('title2') }}
24- </van-button >
9+ <van-button type =" primary" :text =" $t('title2')" @click =" showLoadingToast()" />
10+ <van-button type =" primary" :text =" $t('loadingType')" @click =" showLoadingToast('spinner')" />
2511 </demo-block >
2612
2713 <demo-block :title =" $t('title3')" >
28- <van-button
29- type =" info"
30- @click =" showSuccessToast"
31- >
32- {{ $t('success') }}
33- </van-button >
34- <van-button
35- type =" danger"
36- @click =" showFailToast"
37- >
38- {{ $t('fail') }}
39- </van-button >
14+ <van-button type =" info" :text =" $t('success')" @click =" showSuccessToast" />
15+ <van-button type =" danger" :text =" $t('fail')" @click =" showFailToast" />
4016 </demo-block >
4117
42- <demo-block
43- v-if =" !$attrs.weapp"
44- :title =" $t('customIcon')"
45- >
46- <van-button
47- type =" primary"
48- @click =" showIconToast"
49- >
50- {{ $t('customIcon') }}
51- </van-button >
52-
53- <van-button
54- type =" primary"
55- @click =" showImageToast"
56- >
57- {{ $t('customImage') }}
58- </van-button >
18+ <demo-block v-if =" !$attrs.weapp" :title =" $t('customIcon')" >
19+ <van-button type =" primary" :text =" $t('customIcon')" @click =" showIconToast" />
20+ <van-button type =" primary" :text =" $t('customImage')" @click =" showImageToast" />
5921 </demo-block >
6022
61- <demo-block :title =" $t('advancedUsage')" >
62- <van-button
63- type =" primary"
64- @click =" showCustomizedToast"
65- >
66- {{ $t('advancedUsage') }}
67- </van-button >
23+ <demo-block :title =" $t('updateMessage')" >
24+ <van-button type =" primary" :text =" $t('updateMessage')" @click =" showCustomizedToast" />
6825 </demo-block >
6926 </demo-section >
7027</template >
@@ -85,7 +42,9 @@ export default {
8542 customIcon: ' 自定义图标' ,
8643 customImage: ' 展示图片' ,
8744 text4 : second => ` 倒计时 ${ second} 秒` ,
88- longTextButton: ' 长文字提示'
45+ longTextButton: ' 长文字提示' ,
46+ updateMessage: ' 动态更新提示' ,
47+ loadingType: ' 自定义加载图标'
8948 },
9049 ' en-US' : {
9150 title1: ' Text' ,
@@ -100,13 +59,19 @@ export default {
10059 customIcon: ' Custom Icon' ,
10160 customImage: ' Custom Image' ,
10261 text4 : second => ` ${ second} seconds` ,
103- longTextButton: ' Long Text'
62+ longTextButton: ' Long Text' ,
63+ updateMessage: ' Update Message' ,
64+ loadingType: ' Loading Type'
10465 }
10566 },
10667
10768 methods: {
108- showLoadingToast () {
109- this .$toast .loading ({ forbidClick: true , message: this .$t (' loading' ) });
69+ showLoadingToast (loadingType ) {
70+ this .$toast .loading ({
71+ forbidClick: true ,
72+ message: this .$t (' loading' ),
73+ loadingType
74+ });
11075 },
11176
11277 showSuccessToast () {
@@ -135,7 +100,6 @@ export default {
135100 const toast = this .$toast .loading ({
136101 duration: 0 ,
137102 forbidClick: true ,
138- loadingType: ' spinner' ,
139103 message: this .$t (' text4' , 3 )
140104 });
141105
@@ -155,7 +119,7 @@ export default {
155119 </script >
156120
157121<style lang="less">
158- @import " ../../style/var" ;
122+ @import ' ../../style/var' ;
159123
160124.demo-toast {
161125 background-color : @white ;
0 commit comments