mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
* [bugfix] Checkbox border render error in weixin browser * [bugfix] TreeSelect dependency path error * [bugfix] Swipe should clear autoplay timer when destroyed * [bugfix] Optimize component dependency analyze when build style entry * merge * update yarn.lock * update README.md * update README.md * update README.md * update README.md * update README.md * [Doc] add more badges in README.md * update README.md * [bugfix] Address & Contact list style * fix: contact test cases * [bugfix] popup style missing when build style entry * [bugfix] Search: onSearch event arguments missing * [Doc] add demo pages * update zan-doc@0.3.7 * fix: build entry error * [Doc] add goods demo * [bugfix] button primary background color * [Doc] update doc detail * [new feature] Coupon add 'showExchangeBar' prop && add empty style * [new feature] Toast support `position` prop * [new feature] Tabbar add 'info' prop
69 lines
1.6 KiB
Vue
69 lines
1.6 KiB
Vue
<template>
|
|
<transition name="van-toast-fade">
|
|
<div class="van-toast-wrapper" v-show="visible">
|
|
<div :class="['van-toast', `van-toast--${displayStyle}`, `van-toast--${position}`]">
|
|
<!-- text only -->
|
|
<div v-if="displayStyle === 'text'" class="van-toast__text">{{ message }}</div>
|
|
<div v-if="displayStyle === 'html'" class="van-toast__text" v-html="message" />
|
|
|
|
<!-- with icon -->
|
|
<template v-if="displayStyle === 'default'">
|
|
<van-loading v-if="type === 'loading'" color="white" />
|
|
<van-icon v-else class="van-toast__icon" :name="type" />
|
|
<div v-if="message" class="van-toast__text">{{ message }}</div>
|
|
</template>
|
|
</div>
|
|
<div class="van-toast__overlay" v-if="forbidClick" />
|
|
</div>
|
|
</transition>
|
|
</template>
|
|
|
|
<script>
|
|
import Icon from '../icon';
|
|
import Loading from '../loading';
|
|
|
|
const TOAST_TYPES = ['text', 'html', 'loading', 'success', 'fail'];
|
|
const DEFAULT_STYLE_LIST = ['success', 'fail', 'loading'];
|
|
|
|
export default {
|
|
name: 'van-toast',
|
|
|
|
components: {
|
|
[Icon.name]: Icon,
|
|
[Loading.name]: Loading
|
|
},
|
|
|
|
props: {
|
|
type: {
|
|
type: String,
|
|
default: 'text',
|
|
validator: value => TOAST_TYPES.indexOf(value) > -1
|
|
},
|
|
message: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
forbidClick: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
position: {
|
|
type: String,
|
|
default: 'middle'
|
|
}
|
|
},
|
|
|
|
data() {
|
|
return {
|
|
visible: false
|
|
};
|
|
},
|
|
|
|
computed: {
|
|
displayStyle() {
|
|
return DEFAULT_STYLE_LIST.indexOf(this.type) !== -1 ? 'default' : this.type;
|
|
}
|
|
}
|
|
};
|
|
</script>
|