1,在项目中将icon变成字体图标,
参考以下链接:

https://jingyan.baidu.com/article/d45ad1485e549569552b80c1.html

2.页面操作代码如下

<div v-for='(item,index) in list' :key='index'>
  <span class='margin-left-normal'  @click='bindLike(item,index)'>
           <span :id="'vote'+index">
                    <i class="iconfont icon-dianzan" ></i> 点赞图标
                    <span class=' text-right font-size-smaller  margin-right-small' >{{ item.number}}</span>点赞数量
            </span>
        </span> 
</div>

js部分

<script>
 export defalut{
    data(){
          return {
          countVote :'',
                 list:[
                       {number:1}{number:1}{number:1}]
              }
      },
      methods:{
                bindLike (item, index) {
               this.countVote = item.number
      if (this.countVote != 0) {
        this.showPosition = true 这是用来判断已点赞之后再次点赞的弹框的
      } else {
        document.getElementById('vote' + index).classList.add('red')
        item.number++
        this.showPositionValue = true 这是用来判断点赞的弹框的
      }
    },
        }
 }
</script>
Logo

前往低代码交流专区

更多推荐