zoukankan      html  css  js  c++  java
  • 怎么根据返回数量,来渲染点赞星星的个数变高量?

     <script>
            //假设后台返回的数量为3
            var arr = [false, false, false, false, false]
            arr.splice(0, 3)
            console.log(arr) //[false,false]
            for (var i = 0; i < 3; i++) {
                arr.unshift(true)
    
            }
            console.log(arr, '输出最后一个') // [true, true, true, false, false]
        </script>

    如果用vue或者是avalon,最好直接在html中去判断,其中

    el.score表示的是返回数,然后根据三元表达式去选取class。。。。能用html的千万别用js,麻烦!!!!
     <p style="display: inline-block;">
          <span ms-class="['fishqc-report-xing-small',el.score >=1 ?'fishqc-report-xing-active':'fishqc-report-xing' ]"></span>
          <span ms-class="['fishqc-report-xing-small',el.score >=2 ?'fishqc-report-xing-active':'fishqc-report-xing' ]"></span>
          <span ms-class="['fishqc-report-xing-small',el.score >=3 ?'fishqc-report-xing-active':'fishqc-report-xing' ]"></span>
          <span ms-class="['fishqc-report-xing-small',el.score >=4 ?'fishqc-report-xing-active':'fishqc-report-xing' ]"></span>
          <span ms-class="['fishqc-report-xing-small',el.score >=5 ?'fishqc-report-xing-active':'fishqc-report-xing' ]"></span>
     </p>
  • 相关阅读:
    数据库表的主外键
    数据库条件查询及关系搭建
    MySQL数据库的基本认识与操作
    MySQL5.7安装详解及常见安装问题解决
    数据库介绍
    Sensor图像调试
    1.线性表
    发展建议
    typedef 与 #define 的区别
    音频处理
  • 原文地址:https://www.cnblogs.com/antyhouse/p/8484543.html
Copyright © 2011-2022 走看看