弹出面板,可自定义内容,通常作为基础组件被其他组件依赖。
示例
<nut-popup
:popupVisible.sync="visible1"
:configItems="popup[0]"
@cancel-btn-click="cancelBtnFn"
@ok-btn-click="okBtnFn"
@close-popup="closeMask">
</nut-popup>
<nut-popup
:popupVisible.sync="visible2"
:configItems="popup[1]"
@onlyone-btn-click="onlyOneBtnFn">
</nut-popup>
<nut-popup
:popupVisible.sync="visible3"
:configItems="popup[2]"
@cancel-click="cancelFn"
@ok-click="okFn">
</nut-popup>
仅含有关闭按钮
<nut-popup
:popupVisible.sync="visible4"
:configItems="popup[3]">
</nut-popup>
默认示例
<nut-popup
:popupVisible.sync="visible5"
:configItems="{}">
</nut-popup>
export default {
data(){
return{
visible1: false,
visible2: false,
visible3: false,
visible4: false,
visible5: false,
popup: [
{
randomId: '0',
hasCloseBtn: true,
btnAmount: 2,
popupHeight: {
height: '100px'
},
cancelAutoClose: false
},
{
hasCloseBtn: true,
btnAmount: 1
},
{
hasCloseBtn: false,
popupFooterVisible: false
},
{
hasCloseBtn: true,
popupFooterVisible: false
}
]
}
},
methods:{
popupDemo1() {
this.visible1 = true;
},
popupDemo2() {
this.visible2 = true;
},
popupDemo3() {
this.visible3 = true;
},
popupDemo4() {
this.visible4 = true;
},
popupDemo5() {
this.visible5 = true;
},
cancelBtnFn(e) {
console.log(e.target);
},
okBtnFn(e) {
console.log(e.target);
},
onlyOneBtnFn(e) {
console.log('onlyOneBtnFn')
},
cancelFn(e) {
console.log('cancelFn');
},
okFn(e) {
console.log('okFn');
},
closeMask(e) {
console.log('closePopup');
this.visible1 = false;
}
}
}
Props
参数 | 说明 | 类型 | 默认值 | 可选值 |
---|
popupVisible.sync | 显示状态 | Boolean | false | false/true |
configItems | 配置项 | Object | {} | — |
configItems.randomId | 设置popup组件的顶层id | String | '' | — |
configItems.autoClose | 是否自动关闭蒙层(如果是,需要将popupVisible增加.sync修饰符) | Boolean | true | true/false |
configItems.popupHeaderVisible | 是否显示头部 | Boolean | true | true/false |
configItems.hasCloseBtn | 是否有关闭按钮 | Boolean | true | true/false |
configItems.cancelText | 头部取消按钮文案 | String | 取消 | — |
configItems.cancelClose | 点击头部取消是否关闭面板 | Boolean | true | true/false |
configItems.okText | 头部确定按钮文案 | String | 确定 | — |
configItems.popupFooterVisible | 是否显示底部 | Boolean | true | true/false |
configItems.btnAmount | 底部展示按钮的数量 | Number | 2 | 2/1 |
configItems.onlyOneBtnText | 仅一个按钮文案 | String | 去购买 | — |
configItems.cancelBtnText | 底部取消按钮文案 | String | 取消 | — |
configItems.cancelAutoClose | 点击底部取消按钮是否关闭面板 | Boolean | true | true/false |
configItems.okBtnText | 底部确定按钮文案 | String | 确定 | — |
Events
事件名 | 说明 | 回调参数 |
---|
cancel-click | 点击顶部取消按钮时触发 | 返回Event对象 |
ok-click | 点击顶部确定按钮时触发 | 返回Event对象 |
onlyone-btn-click | 点击底部仅有一个按钮时触发 | 返回Event对象 |
cancel-btn-click | 点击底部取消按钮时触发 | 返回Event对象 |
ok-btn-click | 点击底部取消按钮时触发 | 返回Event对象 |