mirror of
https://github.com/youzan/vant.git
synced 2025-10-20 18:54:24 +00:00
feat(Toast): add closeOnClick option (#4192)
This commit is contained in:
@@ -14,6 +14,7 @@ export default createComponent({
|
||||
iconPrefix: String,
|
||||
loadingType: String,
|
||||
forbidClick: Boolean,
|
||||
closeOnClick: Boolean,
|
||||
message: [Number, String],
|
||||
type: {
|
||||
type: String,
|
||||
@@ -49,8 +50,15 @@ export default createComponent({
|
||||
},
|
||||
|
||||
methods: {
|
||||
onClick() {
|
||||
if (this.closeOnClick) {
|
||||
this.close();
|
||||
}
|
||||
},
|
||||
|
||||
toggleClickable() {
|
||||
const clickable = this.value && this.forbidClick;
|
||||
|
||||
if (this.clickable !== clickable) {
|
||||
this.clickable = clickable;
|
||||
const action = clickable ? 'add' : 'remove';
|
||||
@@ -111,6 +119,7 @@ export default createComponent({
|
||||
bem([this.position, { text: !hasIcon && type !== 'loading' }]),
|
||||
this.className
|
||||
]}
|
||||
onClick={this.onClick}
|
||||
>
|
||||
{ToastIcon()}
|
||||
{Message()}
|
||||
|
Reference in New Issue
Block a user