微信小程序学习之路——导航组件

<navigator/>是小程序种的页面链接,其作用和HTML中超链接标签一样,主要控制页面的跳转,<navigator/>属性如下:

由于内容较多,请参考微信官方文档:https://developers.weixin.qq.com/miniprogram/dev/component/navigator.html

实例代码如下:

<view class="btn-area">
  <navigator url="../navigate/navigate?title=navigate" hover-class="navigator-hover">跳转到新页面</navigator>
  <navigator url="/redirect/redirect?title=redirect" open-type="redirect" hover-class="other-navigator-hover">在当前页打开</navigator>
  <navigator url="/index/index" open-type="switchTab" hover-class="other-navigator-hover">切换 Tab</navigator>
</view>
// redirect.js navigator.js
Page({
  onLoad: function (options) {
    this.setData({
      title: options.title
    })
  }
})
<!-- navigator.wxml -->
<view style="text-align:center"> {{title}} </view>
<view> 点击左上角返回回到之前页面 </view>
<!-- redirect.wxml -->
<view style="text-align:center">{{title}}</view>
<view>点击左上角返回回到上级页面</view>
.navigator-hover {
    color:blue;
}
/** 自定义其他点击态样式类 **/
.other-navigator-hover {
    color:red;
}

框架为:

执行结果如下:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值