账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    vue 如何监听事件动态传至给子组件
    61
    0

    点击后defaultEducation的值明明改变了,但props传给子组件却watch不到

    父组件

    <choice :text="checkdata" ref="choice" @getchoice="onChoice" @cancel="showToggleCancel" :checkedValue="defaultEducation"></choice>
    
    
    computed: {
          geitfasa () {
            document.addEventListener('tap', function (event) {
              var focusTargetDom = event.target
              if (focusTargetDom.tagName.toLowerCase() === 'input' && focusTargetDom.getAttribute('name') === 'checkdata') {
                this.defaultEducation = focusTargetDom.value
                console.log(this.defaultEducation)
              }
            }, true)
          }
        }

    子组件

    <input type="radio" :value="item.id" :id="`checkbox_${index}`" :name="item.radioName" v-model="checkedVal" @tap.stop="hideCheck"/>
            <label :for="`checkbox_${index}`" :id="`check_${index}`">
              {{item.name}}
            </label>
            
     props: {
          text: {
            type: Array,
            default: []
          },
          checkedValue: {
            type: String,
            default: ''
          }
        },
        data () {
          return {
            checkedVal: ''
          }
        },       
     created () {
          this.checkedVal = this.checkedValue
          this.$watch('checkedValue', (newquery) => {
            console.log(newquery)
          })
        }       
            
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 卍魅惑 普通会员 1楼
      { "error": "Failed to generate content." }
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部