feat(Toast): add closeOnClick option (#4192)

This commit is contained in:
neverland
2019-08-22 17:57:25 +08:00
committed by GitHub
parent 5603da5c73
commit d2b28432cd
6 changed files with 35 additions and 2 deletions

View File

@@ -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()}