Vue 通过for循环出来的标签,只改变其中的某一个样式

场景:项目中点击表格的某一个内容,按照该内容的属性进行排序,排序时需要改变排序的样式

 


   {
    {item.name}}


decChange(val,i) {
  //将所有样式重置
  this.$refs.decChange.map(item=>{
  return item.className = 'sortable both'
 })
  //给点击的标签添加一个新的类名
this.$refs.decChange[i].className =  this.$refs.decChange[i].className = 'sortable both'+' desc'
               

主要思想,给点击的标签添加一个新的类名

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