zoukankan      html  css  js  c++  java
  • 小程序 获取前几名加样式

    很多网站的新闻,前几条消息都不同颜色来展示,来突出。

    样式按照自已想法写,我这里就没有贴出来

      wxml主要代码

        <block wx:for="{{ranking}}" wx:for-index="index">
            <view class='ranking' style='border-bottom: 1rpx solid silver;'>
              <view class='ranking-view'>
                  <view class='ranking-font'>     
                    <view class='first' wx:if='{{index === 0}}'>
                      <image src='../../../image/jiang.png'></image>
                    </view>
                    <view class='second' wx:elif='{{index === 1}}'> 
                      <image src='../../../image/jiang1.png'></image>
                    </view>
                    <view class='third' wx:elif='{{index === 2}}'> 
                       <image src='../../../image/jiang2.png'></image>
                    </view>
                    <view class='list-id' wx:else >{{item.num}}</view>
                  </view>
                  <view class='ranking-font'>
                    <view class='first' wx:if='{{index === 0}}'>{{item.name}}</view>
                    <view class='second' wx:elif='{{index === 1}}'>{{item.name}}</view>
                    <view class='third' wx:elif='{{index === 2}}'>{{item.name}}</view>
                    <view class='list-id' wx:else >{{item.name}}</view>
                  </view>
                  <view class='ranking-font'>              
                   <view class='first' wx:if='{{index === 0}}'>{{item.integral}}</view>
                    <view class='second' wx:elif='{{index === 1}}'>{{item.integral}}</view>
                    <view class='third' wx:elif='{{index === 2}}'>{{item.integral}}</view>
                    <view class='list-id' wx:else >{{item.integral}}</view>
                  </view>
              </view>
            </view>
         </block>
    View Code

      js 模拟数据

    ranking: [
          {
            num: '1',
            name: '李珊珊',
            integral: '800',
          },
          {
            num: '2',
            name: '余文',
            integral: '562',
          },
          {
            num: '3',
            name: '高富帅',
            integral: '450',
          },
          {
            num: '4',
            name: '李冰冰',
            integral: '130',
          },
          {
            num: '5',
            name: '紫罗兰',
            integral: '125',
          },
          {
            num: '6',
            name: '张丽丽',
            integral: '120',
          },
          {
            num: '7',
            name: '联欢会',
            integral: '110',
          },
          {
            num: '8',
            name: '张算法',
            integral: '100',
          },
    
       
      
        ],
    View Code

    如图:

      

  • 相关阅读:
    STL
    STL
    Python编程-基础知识-条件判断
    STL
    springmvc 自定义注解
    Springboot 入口类及其实现自动配置的原理
    Java RestTemplate post请求传递参数遇到的坑
    Spring中@Autowire的底层原理解析(附详细源码阅读步骤)
    非常详细的SpringBoot-自动装配原理
    为何一个@LoadBalanced注解就能让RestTemplate拥有负载均衡的能力?
  • 原文地址:https://www.cnblogs.com/LCH-M/p/10160447.html
Copyright © 2011-2022 走看看