2-13 vue click事件里的&&

销户系统

1.vue click事件里的&&

 <div v-if="type === 'stock'&&!isIgnoreCsdc" class="selector" slot="content-1">
          <a
            v-if="!hasError(account)"
            href="javascript:;"
            @click="isChecked(i)&&openSelectRadio(i)"
          >{{cancelCsdc(account.csdcCancelFlag)}}</a>
        </div>

值得注意的是@click="isChecked(i)&&openSelectRadio(i)"的用法,会首先执行isChecked()函数,若为true才会执行openSelectRadio(i),所以经常被用来处理在某一条件下才能触发点击事件的问题

 //判断是否勾选了对应账户,勾选了才可以选择是否销中登账户
  isChecked(index){
    const indexNo = this.checkAccountIndexList.indexOf(index)
    if (~indexNo) {
      return true
    }
    return false
  }

而且isChecked()函数会在每次点击时自动执行,不用进行监听处理。

2.子组件一层层向上传值一定要抓住$emit(),注意观察作用域和传递的值即可

猜你喜欢

转载自blog.csdn.net/qq_36620428/article/details/87189948