小程序

作者: vzii | 来源:发表于2018-09-22 19:46 被阅读0次

    0.脚手架

    npm install -g wepy-cli

    1.生命周期:

    onLoad  监听页面加载

    onShow 监听页面显示

    onReady 监听页面初次渲染完成

    onHide 监听页面隐藏

    2.转发按钮

    <button open-type='share'>分享</button>

    自定义内容函数

    onShareAppMessage:function(){

        return{

          title:'不转不是中国人',

          pata:'/pages/login/login',

          imageUrl:'/image/1.jpg'

        }

      }

    3.绑定输入框

    <input bindinput='bind'/>

    获取输入内容

    bind:function(e){

        console.log(e.detail.value)

      }

    4.绑定参数

    <view bindtap='tab'data-name="myname">点击</view>

    获取参数

    tab:function(e){

       console.log(e.currentTarget.dataset)

      },

    5.上拉函数

    onPullDownRefresh:function(){

        console.log("下拉刷新")

      },

    6.下拉函数

    onReachBottom:function(){

        console.log("上拉刷新")

      },

    7.渲染数据

    数据

    brand:[

          { name: "苹果", phone: ["phone4", "phone5", "phone6", "phone7"]},

          { name: "华为", phone: ["p10", "p11", "p12", "p13"]},

          { name: "小米", phone: ["小米1", "小米2", "小米3", "小米4"]}

        ],

    渲染

    <view wx:for="{{brand}}" wx:key="{{index}}">

      {{item.name}}

      <view wx:for="{{item.phone}}" wx:for-item="sub"

      wx:for-index="subindex" wx:key="{{subindex}}">

      {{sub}}

      </view

    8.判断

    <view wx:if="{{qian > 8000}}">

    买:{{iphonex.name}},价格:{{iphonex.price}}

    </view>

    <view wx:elif="{{qian === 8000}}">

    买:{{iphone8.name}},价格:{{iphone8.price}}

    </view>

    <view wx:else>

    买:{{iphone6.name}},价格:{{iphone6.price}}

    </view>

    相关文章

      网友评论

          本文标题:小程序

          本文链接:https://www.haomeiwen.com/subject/xupxoftx.html