微信小程序用vant组件制作通讯录

微信小程序用vant组件制作通讯录
效果图:
在这里插入图片描述
代码如下:
.wxml:

在这里插入<van-index-bar index-list="{{ indexList }}">
  <view>
    <van-index-anchor index="" use-slot="true">省级负责人</van-index-anchor>
    <view class='user' wx:for='{{provList}}'wx:key='name'>
       <image class='icon' src='{{item.photo}}'></image> 
     <view class='text'>{{item.name}}</view>
    </view>
  </view>

  <view>
    <van-index-anchor  class='title' index="" use-slot="true">市级负责人</van-index-anchor>
    <view class='user' wx:for='{{cityList}}'wx:key='name'>
       <image class='icon' src='{{item.photo}}'></image> 
     <view class='text'>{{item.name}}</view>
    </view>
  </view>
   <view>
    <van-index-anchor index="" use-slot="true">区级负责人</van-index-anchor>
   <view class='user' wx:for='{{districtList}}'wx:key='name'>
       <image class='icon' src='{{item.photo}}'></image> 
     <view class='text'>{{item.name}}</view>
    </view>
  </view>
   <view>
    <van-index-anchor index="" use-slot="true" >镇级负责人</van-index-anchor>
   <view class='user' wx:for='{{townList}}'wx:key='name'>
       <image class='icon' src='{{item.photo}}'></image> 
     <view class='text'>{{item.name}}</view>
    </view>
  </view>
   <view>
    <van-index-anchor index="" use-slot="true">村级负责人</van-index-anchor>
   <view class='user' wx:for='{{villageList}}'wx:key='name'>
       <image class='icon' src='{{item.photo}}'></image> 
     <view class='text'>{{item.name}}</view>
    </view>
  </view>
</van-index-bar>代码片

.js文件

 data: {
    indexList:["省","市","区","镇","村"],
    provList:[
           { 
             name:'李宏伟',
             photo:'/images/1.jpg'
            },
          { name:'赵爱国',
          photo:'/images/2.jpg'
        }
        ],
    cityList:[
      { 
        name:'钱必胜',
        photo:'/images/3.jpg'
       },
     { name:'李美丽',
     photo:'/images/4.jpg'
   }
     
    ],
    districtList:[
      { 
        name:'王爱丽',
        photo:'/images/5.jpg'
       },
     { name:'李秀秀',
     photo:'/images/5.jpg'
   }
    ],
    townList:[
      { 
        name:'马鑫',
        photo:'/images/6.jpg'
       },
     { name:'赵明华',
     photo:'/images/7.jpg'
   }
    ],
     villageList:[
      { 
        name:'赵小妹',
        photo:'/images/8.jpg'
       },
     { name:'周庭',
     photo:'/images/9.jpg'
   },{
     name:"周国伟",
     photo:"/images/3.jpg"
   }
     ]
    ,

   },

.wxss

.user{
  border-bottom: 2rpx gray solid;
  height:38px ;
  display: flex;
}
.icon{
  width: 35px;
  height: 35px;
  border-radius: 10px;
  flex:1;
  margin: 0px 18px;
}
.text{
  margin:0px;
  line-height:38px;
  flex: 8;
}

.json文件

 "usingComponents": {
    "van-index-bar": "/miniprogram_npm/@vant/weapp/index-bar/index",
  "van-index-anchor": "/miniprogram_npm/@vant/weapp/index-anchor/index",
  "van-cell":"/miniprogram_npm/@vant/weapp/cell/index"
  },//引入vant组件
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值