微信小程序之基础组件篇——基础内容(八)

作者: wechat 发布时间: 2021-01-28 浏览: 1372 次 编辑

本篇文章将介绍小程序的基础组件——基础内容。

基础内容分为三大组件:
  • icon——图标
  • text——文本
  • progress——进度条

icon

icon属性


index.wxml
<view class="group">
  <block wx:for="{{iconSize}}">
    <icon type="success" size="{{item}}"/>
  </block>
</view>
<view class="group">
  <block wx:for="{{iconType}}">
    <icon type="{{item}}" size="45"/>
  </block>
</view>
<view class="group">
  <block wx:for="{{iconColor}}">
    <icon type="success" size="45" color="{{item}}"/>
  </block>
</view>
index.js
Page({
  data: {
    iconSize: [20, 30, 40, 50, 60, 70],
    iconColor: [
      'red', 'orange', 'yellow', 'green', 'rgb(0,255,255)', 'blue', 'purple'
    ],
    iconType: [
      'success', 'info', 'warn', 'waiting', 'safe_success', 'safe_warn',
      'success_circle', 'success_no_circle', 'waiting_circle', 'circle', 'download',
      'info_circle', 'cancel', 'search', 'clear'
    ]
  }
})



icon效果图

text

index.wxml
<view class="btn-area">
  <view class="body-view">
    <text>{{text}}</text>
    <button bindtap="add">add line</button>
    <button bindtap="remove">remove line</button>
  </view> </view>
var initData = 'this is first line\nthis is second line'
var extraLine = [];
Page({
  data: {
    text: initData
  },
  add: function(e) {
    extraLine.push('other line')
    this.setData({
      text: initData + '\n' + extraLine.join('\n')
    })
  },
  remove: function(e) {
    if (extraLine.length > 0) {
      extraLine.pop()
      this.setData({
        text: initData + '\n' + extraLine.join('\n')
      })
    }
  }
})


text效果图

progress


<progress percent="20" show-info />
<progress percent="40" stroke-width="12" />
<progress percent="60" color="pink" />
<progress percent="80" active />



progress效果图

微信小程序之入门篇(一)

微信小程序之注册篇(二)

微信小程序之开发初体验(三)——开发工具使用和目录结构

微信小程序之生命周期(四)

微信小程序之数据绑定(五)

微信小程序之触控事件(六)

微信小程序之基础组件篇——视图容器(七)

微信小程序之基础组件篇——基础内容(八)

微信小程序之基础组件篇——表单组件(九)

微信小程序之基础组件篇——导航组件(十)

微信小程序之基础组件篇——媒体组件(十一)

微信小程序之API篇——豆瓣图书搜索(十二)

微信小程序之拓展篇——weui-wxss(十三)