微信小程序之入門篇(一)
微信小程序之注冊篇(二)
微信小程序之開發初體驗(三)——開發工具使用和目錄結構
微信小程序之生命周期(四)
微信小程序之數據綁定(五)
微信小程序之觸控事件(六)
微信小程序之基礎組件篇——視圖容器(七)
微信小程序之基礎組件篇——基礎內容(八)
微信小程序之基礎組件篇——表單組件(九)
微信小程序之基礎組件篇——導航組件(十)
微信小程序之基礎組件篇——媒體組件(十一)
微信小程序之API篇——豆瓣圖書搜索(十二)
微信小程序之拓展篇——weui-wxss(十三)
本篇文章將介紹小程序的基礎組件——導航組件。
導航組件只有一個組件:
- navigator
navigator
/** wxss **/
/** 修改默認的navigator點擊態 **/
.navigator-hover {
color:blue;
}
/** 自定義其他點擊態樣式類 **/
.other-navigator-hover {
color:red;
}
<!-- sample.wxml -->
<view class="btn-area">
<navigator url="navigate?title=navigate" hover-class="navigator-hover">跳轉到新頁面</navigator>
<navigator url="redirect?title=redirect" open-type="redirect" hover-class="other-navigator-hover">在當前頁打開</navigator>
<navigator url="index" open-type="switchTab" hover-class="other-navigator-hover">切換 Tab</navigator>
</view>
<!-- navigator.wxml -->
<view style="text-align:center"> {{title}} </view>
<view> 點擊左上角返回回到之前頁面 </view>
<!-- redirect.wxml -->
<view style="text-align:center"> {{title}} </view>
<view> 點擊左上角返回回到上級頁面 </view>
// redirect.js和navigator.js均為
Page({
onLoad: function(options) {
this.setData({
title: options.title
})
}
})