<template>
<view class="content">
<!-- v-show是相對於display: none -->
<view v-show="false"></view>
<!-- v-if是刪除這個元素 -->
<view v-if="false"></view>
<view>我是文本</view>
<button type="primary" @click="toPath">跳轉注冊頁面</button>
<button type="primary" @click="toPath1">跳轉未注冊頁面</button>
<button type="primary" @click="toPath2">關閉當前頁面再跳轉</button>
<button type="primary" @click="toPath3">可以返回幾層頁面 默認為一層</button>
</view>
</template>
<script>
import test from "../../components/test.vue"
export default {
data() {
return {
msg: "小白",
}
},
methods: {
toPath() {
// 這個用於跳轉到Tab注冊過的頁面
uni.switchTab({
url: "../shezhi/shezhi"
})
},
toPath1() {
// 這個可以跳轉到未在tab注冊的頁面,跳轉是時注意這個會保留當前頁面重新打開新的頁面 一般用於要返回的頁面
uni.navigateTo({
// 在跳轉的地址后面傳參
url: "../one/one?name=huoyan"
});
},
toPath2(){
// 關閉當前頁面之后再進行跳轉
uni.redirectTo({
url: "../one/one"
})
},
toPath3(){
// 返回上層頁面 不填參數默認為1
uni.navigateBack({
delta: 1
});
}
},
}
</script>