vant/packages/toast/toast.vue
neverland 257654ff03
[new feature] toast add mask option (#296)
* [bugfix] CouponList always show empty info

* [bugfix] add click feedback of buttons in components

* [Doc] add custom theme document

* [new feature] Notice bar support more props

* [bugfix] PullRefresh test cases

* [bugfix] unused NoticeBar style

* [bugfix] Swipe width calc error

* [Doc] english document of all action components

* [Doc] change document site path to /zanui/vant

* [Doc] fix

* [bugfix] uploader style error

* [bugfix] tabs document demo

* [new feature] Cell support vue-router target route

* [bugfix] add cell test cases

* update yarn.lock

* [bugfix] Tabbar cann't display info when use icon slot

* [Doc] update document title

* [bugfix] Dialog should reset button text when showed

* [new feature] CouponList add showCloseButton prop

* [new feature] Swipe add 'initialSwipe' prop

* [bugfix] NoticeBar text disappeared when page back

* [new feature] ImagePreview support startPosition

* fix: improve imagePreview test cases

* [bugfix] Steps style error when has more than 4 items

* [new feature] normalize size of all icons

* [new feature] Stepper add plus & minus event

* fix: yarn.lock

* [bugfix] addressEdit icon render failed

* [new feature] toast add mask option
2017-11-09 01:08:46 -06:00

73 lines
1.7 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'">{{ message }}</div>
<div v-if="displayStyle === 'html'" 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', { 'van-toast__overlay--mask': mask }]" v-if="forbidClick || mask" />
</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'
},
mask: {
type: Boolean,
default: false
}
},
data() {
return {
visible: false
};
},
computed: {
displayStyle() {
return DEFAULT_STYLE_LIST.indexOf(this.type) !== -1 ? 'default' : this.type;
}
}
};
</script>