x-modal.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <!-- 模态框 -->
  3. <view class="card_modal center_in" v-if="showModal">
  4. <view class="card_lk">
  5. <view class="modal_title">{{title}}</view>
  6. <view class="btn_modal">
  7. <view class="item_btn center_in" @click="close">取消</view>
  8. <view class="item_btn center_in" style="color: #f1a532;">删除</view>
  9. </view>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. name: 'x-modal',
  16. props: {
  17. show: {
  18. type: Boolean,
  19. default () {
  20. return false
  21. }
  22. },
  23. title: {
  24. type: String,
  25. default () {
  26. return ''
  27. }
  28. },
  29. },
  30. watch: {
  31. show: {
  32. handler(newVal) {
  33. if (newVal) {
  34. this.showModal = true
  35. } else {
  36. this.showModal = false
  37. }
  38. },
  39. deep: true // 开启深度监听
  40. }
  41. },
  42. data() {
  43. return {
  44. showModal: false,
  45. }
  46. },
  47. methods:{
  48. close(){
  49. this.$emit('close')
  50. }
  51. }
  52. }
  53. </script>
  54. <style lang="scss" scoped>
  55. .card_modal {
  56. position: fixed;
  57. z-index: 10070;
  58. inset: 0px;
  59. background-color: rgba(0, 0, 0, 0.5);
  60. }
  61. .card_lk {
  62. width: 60%;
  63. display: flex;
  64. flex-direction: column;
  65. background-color: #fff;
  66. border-radius: 30rpx;
  67. }
  68. .modal_title {
  69. text-align: center;
  70. font-size: 30rpx;
  71. font-weight: 600;
  72. padding: 30rpx 50rpx;
  73. }
  74. .btn_modal {
  75. display: flex;
  76. border-top: 1rpx solid #e7e6e4;
  77. }
  78. .item_btn {
  79. flex: 1;
  80. padding: 20rpx;
  81. font-size: 30rpx;
  82. font-weight: 600;
  83. }
  84. .item_btn:nth-child(1) {
  85. border-right: 1rpx solid #e7e6e4;
  86. }
  87. </style>