vue 父传子(比如点击详情弹框)

父页面点击事件

详情

掉用点击方法

agreeWith(val){
      this.agreeWithChild = val
      this.dialogFlagagreeWith = true
    },

在data定义

agreeWithChild:{},
dialogFlagagreeWith:false

在components 注册组件

'agreewith-dialog': () => import('./agreewith_dialog.vue'),
 

子页面

正常写弹框

子页面用props接收

props: {
    dialogFlag: { // 弹窗的true/false
      type: Boolean,
      default: false
    },
    editDetails: { // 点击所在行的数据
      type: Object,
      default: () => {
      }
    }
  },

还需要在watch监听下弹框的状态

 watch: {
    dialogFlag() {
      this.RoleDetail = this.dialogFlag
    }
  },

你可能感兴趣的:(vue.js,javascript,前端)