• vue 通用弹框封装(van-popup为vant框架基础组件)


    注意:

    没有安装vant或element会运行不了,需按提示安装vant 或element  

    vant-popup效果图(用于手机端):

    组件com-select-time.vue(需要安装vant,所有页面可引用此组件)

    1. <template>
    2. <div class="com-select-time">
    3. <van-popup class="popup-style" v-model="showSelectTime">
    4. <div class="select-time-panel">弹框封装(弹框内容)div>
    5. van-popup>
    6. div>
    7. template>
    8. <script>
    9. export default {
    10. props: {
    11. value: {
    12. type: Boolean,
    13. default: true,
    14. },
    15. },
    16. components: {},
    17. data() {
    18. return {};
    19. },
    20. computed: {
    21. // 监测弹框是否显示
    22. showSelectTime: {
    23. get() {
    24. return this.value;
    25. },
    26. set(val) {
    27. this.$emit('input', val);
    28. },
    29. },
    30. },
    31. watch: {},
    32. methods: {},
    33. created() {},
    34. mounted() {},
    35. beforeCreate() {},
    36. beforeMount() {},
    37. beforeUpdate() {},
    38. updated() {},
    39. beforeDestroy() {},
    40. destroyed() {},
    41. activated() {},
    42. };
    43. script>
    44. <style scoped>
    45. .popup-style {
    46. background-color: transparent;
    47. }
    48. .select-time-panel {
    49. width: 324px;
    50. height: 360px;
    51. background: #ffffff;
    52. border-radius: 8px;
    53. display: flex;
    54. align-items: center;
    55. justify-content: center;
    56. font-size: 28px;
    57. font-family: PingFangSC-Medium, PingFang SC;
    58. font-weight: 500;
    59. color: #0743ea;
    60. }
    61. style>

    页面引用 com-select-time.vue组件

    1. <template>
    2. <div class="check-in-information com-purple-bg">
    3. //默认显示,点击关闭
    4. <div @click="hiddenDialog"></div>
    5. //组件
    6. <com-select-time v-model="showSelectTime"></com-select-time>
    7. </div>
    8. </template>
    9. <script>
    10. export default {
    11. components: {
    12. 'com-select-time': () => import('@/pages/fbec-hotel/components/com-select-time.vue'),//引入弹框组件
    13. },
    14. data() {
    15. return {
    16. showSelectTime:true,//控制弹框显示关闭
    17. };
    18. },
    19. methods: {
    20. hiddenDialog(){
    21. this.showSelectTime=false
    22. }
    23. }
    24. };
    25. </script>

    效果图(用于电脑端):

     end-of-evaluation-dialog.vue组件(需要安装element,所有页面可引用此组件)

    1. <template>
    2. <div class="end-of-evaluation-dialog">
    3. <el-dialog
    4. title=""
    5. :visible.sync="endVisible"
    6. :showEnd="showEnd"
    7. @close="$emit('update:showEnd', false)"
    8. width="18%"
    9. style="margin-top: 20vh"
    10. >
    11. <div class="flex-column-center-center">
    12. <div class="jtl-dialog-icon">
    13. <i class="el-icon-warning"></i>
    14. </div>
    15. <div class="reminder-text">温馨提示</div>
    16. <div class="end-of-evaluation">参评报名已结束,可联系主办方参会</div>
    17. </div>
    18. <div class="flex-center-center">
    19. <span slot="footer" class="dialog-footer">
    20. <el-button type="primary" @click="endVisible = false"
    21. >我知道了</el-button
    22. >
    23. </span>
    24. </div>
    25. </el-dialog>
    26. </div>
    27. </template>
    28. <script>
    29. export default {
    30. name: "end-of-evaluation-dialog",
    31. props: {
    32. showEnd: {
    33. type: Boolean,
    34. default: false,
    35. },
    36. },
    37. components: {},
    38. data() {
    39. return {
    40. endVisible: this.showEnd,
    41. };
    42. },
    43. computed: {},
    44. watch: {
    45. showEnd() {
    46. this.endVisible = this.showEnd;
    47. },
    48. },
    49. methods: {},
    50. created() {},
    51. mounted() {},
    52. beforeCreate() {},
    53. beforeMount() {},
    54. beforeUpdate() {},
    55. updated() {},
    56. beforeDestroy() {},
    57. destroyed() {},
    58. activated() {},
    59. };
    60. </script>
    61. <style lang='scss' scoped>
    62. .end-of-evaluation-dialog {
    63. .el-dialog__headerbtn {
    64. font-size: 0.3rem !important;
    65. }
    66. .jtl-dialog-icon {
    67. .el-icon-warning {
    68. color: #0743ea;
    69. font-size: 0.36rem;
    70. }
    71. }
    72. .reminder-text {
    73. font-size: 0.2rem;
    74. font-family: PingFangSC-Medium, PingFang SC;
    75. font-weight: 500;
    76. color: rgba(0, 0, 0, 0.85);
    77. line-height: 0.22rem;
    78. margin: 0.16rem 0 0.12rem 0;
    79. }
    80. .end-of-evaluation {
    81. font-size: 0.18rem;
    82. font-family: PingFangSC-Regular, PingFang SC;
    83. font-weight: 400;
    84. color: #666666;
    85. line-height: 0.22rem;
    86. margin-bottom: 0.37rem;
    87. white-space: nowrap;
    88. }
    89. .el-button--primary {
    90. background-color: #0743ea;
    91. border-color: #0743ea;
    92. }
    93. }
    94. </style>

     页面引用 end-of-evaluation-dialog.vue组件:

    1. <template>
    2. <div class="check-in-information com-purple-bg">
    3. //默认关闭弹框,点击显示
    4. <div @click="showDialog"></div>
    5. //组件
    6. <end-of-evaluation-dialog class="pc-el" :showEnd.sync="showEnd"></end-of-evaluation-dialog>
    7. </div>
    8. </template>
    9. <script>
    10. export default {
    11. components: {
    12. 'end-of-evaluation-dialog': () => import('@/components/golden/end-of-evaluation-dialog.vue'),//引入弹框组件
    13. },
    14. data() {
    15. return {
    16. showEnd:false,//控制弹框显示关闭
    17. };
    18. },
    19. methods: {
    20. showDialog(){
    21. this.showEnd=true
    22. }
    23. }
    24. };
    25. </script>

  • 相关阅读:
    CMake使用基础汇总
    PyCharm鼠标控制字体缩放
    python-0006-django路由
    第 368 场 LeetCode 周赛题解
    闭关之 C++ 函数式编程笔记(五):系统设计和程序测试
    VUE、.NET多文件的上传、接收
    List介绍
    DBeaver安装与使用教程
    2023年R1快开门式压力容器操作证模拟考试题库及R1快开门式压力容器操作理论考试试题
    JavaScript运算符(运算符(算数运算符,递增和递减运算符,比较运算符,逻辑运算符,赋值运算符)、运算符优先级)
  • 原文地址:https://blog.csdn.net/leng0920/article/details/127587196