2020-02-04 14:55:55 +08:00
|
|
|
# 遮罩关闭
|
2020-05-30 21:41:10 +08:00
|
|
|
你可以在使用 v-model 的时候让点击遮罩不关闭。
|
2020-02-04 14:55:55 +08:00
|
|
|
```html
|
|
|
|
<n-button
|
2020-03-20 12:14:34 +08:00
|
|
|
@click="modalActive = true"
|
2020-02-04 14:55:55 +08:00
|
|
|
>
|
2020-03-05 13:45:45 +08:00
|
|
|
来吧
|
2020-02-04 14:55:55 +08:00
|
|
|
</n-button>
|
|
|
|
<n-modal
|
2020-03-20 12:14:34 +08:00
|
|
|
v-model="modalActive"
|
2020-02-04 14:55:55 +08:00
|
|
|
:mask-closable="false"
|
|
|
|
preset="confirm"
|
|
|
|
title="确认"
|
|
|
|
content="你确认"
|
|
|
|
:closable="false"
|
|
|
|
positive-text="确认"
|
|
|
|
@positive-click="submitCallback"
|
|
|
|
@negative-click="cancelCallback"
|
|
|
|
negative-text="算了"
|
|
|
|
/>
|
|
|
|
```
|
|
|
|
```js
|
|
|
|
export default {
|
|
|
|
data () {
|
|
|
|
return {
|
2020-03-20 12:14:34 +08:00
|
|
|
modalActive: false,
|
2020-02-04 14:55:55 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
cancelCallback () {
|
|
|
|
this.$NMessage.success('算了')
|
2020-03-20 12:14:34 +08:00
|
|
|
this.modalActive = false
|
2020-02-04 14:55:55 +08:00
|
|
|
},
|
|
|
|
submitCallback () {
|
|
|
|
this.$NMessage.success('确认')
|
2020-03-20 12:14:34 +08:00
|
|
|
this.modalActive = false
|
2020-02-04 14:55:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|