关于绑定属性
来源:14-11 电子书列表高级优化
 
			lipapa
2020-08-26
  <p
                  @click="pickOut(index, $event)"
                  ref="dataNum" 
                  v-for="(item,index) in goodsInfo.product.productMaterialRelaList"
                  :key="'show'+index"
                  :class="{active:active === index}"
                  :name="item.productsMaterialId"
                  :id="item.materialInst.stockSale"
                  :title="goodsInfo.goodsPrice"
                  :content="item.materialId"
                  :prodid="item.prodId"
                  :ismust="item.isMust"
                  :teamrelation="item.teamRelation"
                  :isperdeposits="false"
                >{{item.materialInst.materialName +' - '+item.materialInst.moddle}}</p>
                  pickOut(index, event) {
      this.active = index;
      // let el = event.currentTarget;
      //console.log(event.currentTarget);
      console.log(event.target);
      console.log(this.$refs.dataNum[index].attributes.name.value);
    },
除了用refs,还有什么好的方法可以动态绑定属性后 通过点击获取相应的dom上的属性!
写回答
	1回答
- 
				
				同学你好,你可以在要获取的元素上绑定事件@click="xx($event)”,通过$event获取DOM元素的属性值。如果帮到了你欢迎采纳。 012020-08-28
相似问题
