• shell编程
...

学习打卡04 小程序03

lyqiuyo 2021-12-05 16:30:32

一、flex布局

  1. {
  2.  "pages":[
  3.    "pages/index/index"
  4. ],
  5.  "window":{
  6.    "navigationBarBackgroundColor": "#000000",   //黑色
  7.    "navigationBarTitleText": "发现"       //导航标题
  8. },
  9.  "sitemapLocation": "sitemap.json"    //配置其小程序页面是否允许为微信索引
  10. }
  1. <!--index.wxml-->
  2. <view class = "container">
  3.  <view class="listGroup" wx:for="{{list}}" wx:for-item="value" wx:key="value{{index}}">
  4.    <view class="listItem" wx:for="{{value}}" wx:for-item="value1" wx:key="value{{index}}">
  5.    <image src="{{value1.icon}}"></image>
  6.    <text>{{value1.text}}</text>
  7.    <image></image>
  8.    </view>
  9.  </view>
  10. </view>
  1. /**index.wxss**/
  2. .container{
  3.  height: 100vh;                       //100视窗
  4.  background-color: silver;           //背景色 银色
  5.  display: flex;                       //flex布局
  6.  flex-direction: column;             //垂直布局
  7. }
  8. .listGroup{
  9.  background-color: white;              
  10.  margin: 20rpx 0;                   //元素边缘 上下外边距20rpx 左右距离为0
  11. }
  12. .listItem{
  13.  display: flex;
  14.  flex-direction: row;
  15.  align-items: center;
  16.  border: 1rpx solid silver;
  17.  padding: 10rpx;
  18. }
  19. image{
  20.  width: 80rpx;
  21.  height: 80rpx;
  22.  margin: 0 15rpx;
  23. }

二、循环创建栏目

  1. // index.js
  2. Page({
  3.  /**
  4.   * 页面的初始数据
  5.   */
  6.  data: {
  7.    list: [
  8.     [
  9.       {text:'朋友圈',icon:''}
  10.     ],
  11.     [
  12.       {text:'扫一扫',icon:''},
  13.       {text:'摇一摇',icon:''}
  14.     ],
  15.     [
  16.       {text:'搜一搜',icon:''},
  17.       {text:'搜一搜',icon:''}
  18.     ],
  19.     [
  20.       {text:'购物',icon:''},
  21.       {text:'游戏',icon:''}
  22.     ],
  23.     [
  24.       {text:'小程序',icon:''}
  25.     ],
  26.   ]
  27. }
  28. })

wxml中绑定循环,用 wx:for, wx:for-item 取别名, wx:key 当前的key值,{{index}}表示当前的索引值

...全文
给本帖投票
120 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

67,943

社区成员

发帖
与我相关
我的任务
社区描述
灌水发信息每周送书 灌水发干货每周送惊喜 谁最水过年送大礼 谁最硬核过年送大礼 谁最贡献过年送大礼
社区管理员
  • 1_bit
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

我们“新手村”社区就是大家的孵化器

你们学习,我来评分

每周最高分送一本书

每月第四周送一份机械键盘

咱们新手村使用一切狂暴手段让优秀的人得到奖励

 

试试用AI创作助手写篇文章吧

手机看
关注公众号

关注公众号

客服 返回
顶部