vue中ref的动态绑定与获取

// 数据
export default {
  data() {
    return {
      list: [
        '今天要修复一百个bug',
        '今天要修复一百个bug',
        '今天要修复一百个bug',
        '今天要修复一百个bug',
        '今天要修复一百个bug',
        '今天要修复一百个bug',
      ],
    };
  },
}

// 循环数据
// :ref="'a'+变量"
{{item}}
// 获取数据 // this.$refs[`a${index}`] 是个数组 fun(index){ if(this.$refs[`a${index}`][0].className==''){ this.$refs[`a${index}`][0].className = 'current'; }else{ this.$refs[`a${index}`][0].className = ''; } }

你可能感兴趣的:(vue2,vue.js)