天天看點

Uni-App - 元件 - 導航

navigator

屬性名 類型 預設值 說明 平台支援

url String  應用内的跳轉連結,值為相對路徑或絕對路徑,如:"../first/first","/pages/first/first",注意不能加 .vue 字尾 

open-type String navigate 跳轉方式 

delta Number  當 open-type 為 'navigateBack' 時有效,表示回退的層數 

hover-class String navigator-hover 指定點選時的樣式類,當hover-class="none"時,沒有點選态效果 

hover-stop-propagation Boolean false 指定是否阻止本節點的祖先節點出現點選态 微信小程式

hover-start-time Number 50 按住後多久出現點選态,機關毫秒 

hover-stay-time Number 600 手指松開後點選态保留時間,機關毫秒

open-type

值 說明 平台支援

navigate 對應 uni.navigateTo 的功能 

redirect 對應 uni.redirectTo 的功能 

switchTab 對應 uni.switchTab 的功能 

reLaunch 對應 uni.reLaunch 的功能 微信小程式

navigateBack 對應 uni.navigateBack 的功能 微信小程式

注:navigator-hover 預設為 {background-color: rgba(0, 0, 0, 0.1); opacity: 0.7;}, <navigator> 的子節點背景色應為透明色。

示例:

<template>
    <view>
        <view class="page-body">
            <view class="btn-area">
                <navigator url="navigate/navigate?title=navigate" hover-class="navigator-hover">
                    <button type="default">跳轉到新頁面</button>
                </navigator>
                <navigator url="redirect/redirect?title=redirect" redirect hover-class="other-navigator-hover">
                    <button type="default">在目前頁打開</button>
                </navigator>
            </view>
        </view>
    </view>
</template>
export default {
    data() {
        return {
            title: 'navigator'
        }
    },
    methods: {
    }
}      

頁面傳值及接收

<template>
    <view>
        <view class="page-body">
            <view class="btn-area">
                <navigator url="./test?title=navigate" hover-class="navigator-hover">
                    <button type="default">跳轉到新頁面</button>
                </navigator>
            </view>
        </view>
    </view>
</template>      
<script>
export default {
 data:{},
 onLoad:function(options){
  console.log(options);
  console.log(options.title);
 }
}
</script>      

繼續閱讀