【小程序自学笔记(二)】入门||页面跳转||触发事件

step by step.

目录

页面跳转

代码

触发事件BindViewTap

触碰鼠标catchtouchcancel

效果


页面跳转

代码

wxml:
<view class="bottomtext" style="width: 728rpx; height: 200rpx; display: block; box-sizing: content-box; left: NaNrpx; top: NaNrpx">
  <view style="width: 728rpx; height: 72rpx; display: block; box-sizing: border-box; left: NaNrpx; top: NaNrpx">要开心地制作小程序哦~
    <view
      style="position: relative; width: 750rpx; background: #d ; min-height: 100px; height: 200rpx; display: block; box-sizing: border-box; left: 4rpx; top: -244rpx">

      <icon style="position: relative; left: -264rpx; top: 62rpx" type="success" size="46"></icon>

      <icon style="position: relative; left: -140rpx; top: 60rpx" type="success" size="46"></icon>

      <icon style="position: relative; left: -44rpx; top: 60rpx" type="success" size="46"></icon>

      <icon style="position: relative; left: 50rpx; top: 60rpx" type="success" size="46"></icon>

      <icon style="position: relative; left: 148rpx; top: 61rpx" type="success" size="46" catchtap="bindViewTap"
        catchtouchcancel="bindViewTap"></icon>

      <text style="position: relative; left: 52rpx; top: 85rpx">我的主页</text>
    </view>
  </view>

有触发事件的是:最后一个icon

触发事件BindViewTap

触碰鼠标catchtouchcancel

      <icon style="position: relative; left: 148rpx; top: 61rpx" type="success" size="46" catchtap="bindViewTap"
        catchtouchcancel="bindViewTap"></icon>

然后在同一文件夹的js文件中添加方法:

  // 事件处理函数
  bindViewTap() {
    wx.navigateTo({
      url: '/pages/myPages'
    })
  },

url为跳转链接:不用写具体文件,写囊括的那个同名文件夹即可。

效果

 先学这么多,拜拜。


版权声明:本文为weixin_51159944原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。