小程序原生组件

2021-03-23  本文已影响0人  云之一

1、view

view组件属性:

2、 text

3、image
4、swiper swiper-item
<swiper easing-function="linear" indicator-active-color="#009400" indicator-color="#ff0094" indicator-dots interval="3000" autoplay circular bindchange="handleSwiperChange" bindtransition="handleTransition" bindanimationfinish="handleAnimationFinish">
  <swiper-item>
    <image mode="widthFix" src="//img11.360buyimg.com/da/s1180x940_jfs/t1/151531/34/2268/47193/5f86fafcE2d14dd84/7cb79c903caf312c.jpg.webp" />
  </swiper-item>
  <swiper-item>
    <image mode="widthFix" src="//img12.360buyimg.com/babel/s1180x940_jfs/t1/158177/13/12306/106725/604aeb77E87226144/c080abd2d3984726.jpg.webp" />
  </swiper-item>
  <swiper-item>
    <image mode="widthFix" src="//img11.360buyimg.com/da/s1180x940_jfs/t1/123642/33/14861/71547/5f86f9d9E23cbc399/3249810484186a2a.jpg.webp"/>
  </swiper-item>
  <swiper-item>
    <image mode="widthFix" src="//imgcps.jd.com/ling4/4808741/54iG5qy-5aW96LSn6LSt/6YOo5YiG5aW96LSn5LmwMei1oDE/p-5bd8253082acdd181d02fa37/1a8be69a/cr/s/q.jpg"/>
  </swiper-item>
</swiper>
Page({
  /**
   * 页面的初始数据
   */
  data: {

  },
  handleSwiperChange(e){
    console.log('current:',e.detail.current)
    console.log('source:',e.detail.source)
  },
  handleTransition(e) {
    // console.log(e)
  },
  handleAnimationFinish(e){
    console.log(e)
  }
})
5、navigator

1.url:跳转路径
2.属性open-type类型:

6、rich-text
7、button

1、属性plain 按钮是否镂空
2、loading 文本前是否显示加载中图标
3、开放能力

<button open-type="contact">contact</button>    
<button open-type="share">share</button>    
<button open-type="getPhoneNumber" bindgetphonenumber="getPhone">getPhoneNumber</button>    
<button open-type="getUserInfo" bindgetuserinfo="getUserInfo">getUserInfo</button>
<button open-type="launchApp">launchApp</button>
<button open-type="openSetting">openSetting</button>    
<button open-type="feedback">feedback</button>
Page({
  getPhone(e) {
    console.log(e)
  },
  getUserInfo(e){
    console.log(e.detail.userInfo)
  }
})
//用户个人信息数据
{
    avatarUrl: "https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTKZCFYXHEIoFDCJCOPk4G2Fm1hNqGnT7l901qiajYhdnCF1ytFtT4j7lqAw0qXZnT5P 
    ib5SNZMPbnng/132"
    city: "Haidian"
    country: "China"
    gender: 1
    language: "zh_CN"
    nickName: "Luo Zongxiang"
    province: "Beijing"
}
8、单选 radio-group/radio
<radio-group bindchange="handleChange">
  <radio color="#000099" value="male">男</radio>
  <radio color="#000099" value="womale">女</radio>
</radio-group>
<view>{{gender}}</view>
Page({
  data:{
    gender:''
  },
  handleChange(e){
    console.log(e.detail.value)
    this.setData({
      gender:e.detail.value
    })
  }
})
9、checkbox-group/checkbox
<checkbox-group bindchange="handleCheckChange">
  <checkbox wx:for="{{list}}" value="{{item.value}}" wx:key="id">{{item.name}}</checkbox>
</checkbox-group>
<view>{{selected}}</view>
Page({
  data:{
    list:[
      {
        id:0,
        name:'香蕉',
        value:'banana'
      },
      {
        id:0,
        name:'苹果',
        value:'apple'
      },
      {
        id:0,
        name:'梨子',
        value:'pear'
      },
      {
        id:0,
        name:'西瓜',
        value:'melon'
      }
    ],
    selected:''
  },
  handleCheckChange(e){
    console.log(e.detail.value)
    this.setData({
      selected:e.detail.value
    })
  }
上一篇 下一篇

猜你喜欢

热点阅读