Popup


弹出面板,可自定义内容,通常作为基础组件被其他组件依赖。

示例
  1. <nut-popup
  2. :popupVisible.sync="visible1"
  3. :configItems="popup[0]"
  4. @cancel-btn-click="cancelBtnFn"
  5. @ok-btn-click="okBtnFn"
  6. @close-popup="closeMask">
  7. </nut-popup>

  1. <nut-popup
  2. :popupVisible.sync="visible2"
  3. :configItems="popup[1]"
  4. @onlyone-btn-click="onlyOneBtnFn">
  5. </nut-popup>

header含有两个操作按钮
  1. <nut-popup
  2. :popupVisible.sync="visible3"
  3. :configItems="popup[2]"
  4. @cancel-click="cancelFn"
  5. @ok-click="okFn">
  6. </nut-popup>

仅含有关闭按钮
  1. <nut-popup
  2. :popupVisible.sync="visible4"
  3. :configItems="popup[3]">
  4. </nut-popup>

默认示例
  1. <nut-popup
  2. :popupVisible.sync="visible5"
  3. :configItems="{}">
  4. </nut-popup>

  1. export default {
  2. data(){
  3. return{
  4. visible1: false,
  5. visible2: false,
  6. visible3: false,
  7. visible4: false,
  8. visible5: false,
  9. popup: [
  10. {
  11. randomId: '0',
  12. hasCloseBtn: true,
  13. btnAmount: 2,
  14. popupHeight: {
  15. height: '100px'
  16. },
  17. cancelAutoClose: false
  18. },
  19. {
  20. hasCloseBtn: true,
  21. btnAmount: 1
  22. },
  23. {
  24. hasCloseBtn: false,
  25. popupFooterVisible: false
  26. },
  27. {
  28. hasCloseBtn: true,
  29. popupFooterVisible: false
  30. }
  31. ]
  32. }
  33. },
  34. methods:{
  35. popupDemo1() {
  36. this.visible1 = true;
  37. },
  38. popupDemo2() {
  39. this.visible2 = true;
  40. },
  41. popupDemo3() {
  42. this.visible3 = true;
  43. },
  44. popupDemo4() {
  45. this.visible4 = true;
  46. },
  47. popupDemo5() {
  48. this.visible5 = true;
  49. },
  50. cancelBtnFn(e) {
  51. console.log(e.target);
  52. },
  53. okBtnFn(e) {
  54. console.log(e.target);
  55. },
  56. onlyOneBtnFn(e) {
  57. console.log('onlyOneBtnFn')
  58. },
  59. cancelFn(e) {
  60. console.log('cancelFn');
  61. },
  62. okFn(e) {
  63. console.log('okFn');
  64. },
  65. closeMask(e) {
  66. console.log('closePopup');
  67. this.visible1 = false;
  68. }
  69. }
  70. }

Props
参数说明类型默认值可选值
popupVisible.sync显示状态Booleanfalsefalse/true
configItems配置项Object{}
configItems.randomId设置popup组件的顶层idString''
configItems.autoClose是否自动关闭蒙层(如果是,需要将popupVisible增加.sync修饰符)Booleantruetrue/false
configItems.popupHeaderVisible是否显示头部Booleantruetrue/false
configItems.hasCloseBtn是否有关闭按钮Booleantruetrue/false
configItems.cancelText头部取消按钮文案String取消
configItems.cancelClose点击头部取消是否关闭面板Booleantruetrue/false
configItems.okText头部确定按钮文案String确定
configItems.popupFooterVisible是否显示底部Booleantruetrue/false
configItems.btnAmount底部展示按钮的数量Number22/1
configItems.onlyOneBtnText仅一个按钮文案String去购买
configItems.cancelBtnText底部取消按钮文案String取消
configItems.cancelAutoClose点击底部取消按钮是否关闭面板Booleantruetrue/false
configItems.okBtnText底部确定按钮文案String确定
Events
事件名说明回调参数
cancel-click点击顶部取消按钮时触发返回Event对象
ok-click点击顶部确定按钮时触发返回Event对象
onlyone-btn-click点击底部仅有一个按钮时触发返回Event对象
cancel-btn-click点击底部取消按钮时触发返回Event对象
ok-btn-click点击底部取消按钮时触发返回Event对象