[new feature] Toast: add icon prop (#3485)

This commit is contained in:
neverland
2019-06-12 17:21:59 +08:00
committed by GitHub
parent 2d18f67a7d
commit 153fb9d69f
15 changed files with 185 additions and 48 deletions

View File

@@ -39,6 +39,22 @@
</van-button>
</demo-block>
<demo-block :title="$t('customIcon')">
<van-button
type="primary"
@click="showIconToast"
>
{{ $t('customIcon') }}
</van-button>
<van-button
type="primary"
@click="showImageToast"
>
{{ $t('customImage') }}
</van-button>
</demo-block>
<demo-block :title="$t('advancedUsage')">
<van-button
type="primary"
@@ -63,6 +79,8 @@ export default {
longText: '这是一条长文字提示,超过一定字数就会换行',
text2: '成功文案',
text3: '失败文案',
customIcon: '自定义图标',
customImage: '展示图片',
text4: second => `倒计时 ${second}`,
longTextButton: '长文字提示'
},
@@ -76,6 +94,8 @@ export default {
longText: 'This is a long message, text will wrap when over a certain length',
text2: 'Success',
text3: 'Fail',
customIcon: 'Custom Icon',
customImage: 'Custom Image',
text4: second => `${second} seconds`,
longTextButton: 'Long Text'
}
@@ -94,6 +114,20 @@ export default {
this.$toast.fail(this.$t('text3'));
},
showIconToast() {
this.$toast({
message: this.$t('customIcon'),
icon: 'like-o'
});
},
showImageToast() {
this.$toast({
message: this.$t('customImage'),
icon: 'https://img.yzcdn.cn/vant/logo.png'
});
},
showCustomizedToast() {
const toast = this.$toast.loading({
duration: 0,