提交 6015c53b 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

feat(setNavigationBarColor): 不同平台跳转对应自定义导航栏示例

上级 d1848671
<template> <template>
<page-head title="setNavigationBarColor"></page-head> <page-head title="setNavigationBarColor"></page-head>
<view class="uni-padding-wrap uni-common-mt"> <view class="uni-padding-wrap uni-common-mt">
<button @tap="setNavigationBarColor1" class="uni-btn"> <button @tap="setNavigationBarColor1" class="uni-btn">
设置导航条背景绿色,标题白色 设置导航条背景绿色,标题白色
</button> </button>
<button @tap="setNavigationBarColor2" class="uni-btn"> <button @tap="setNavigationBarColor2" class="uni-btn">
设置导航条背景红色,标题黑色 设置导航条背景红色,标题黑色
</button> </button>
<button @tap="goNavbarLite" class="uni-btn"> <!-- #ifdef WEB -->
跳转自定义导航栏页面 <button @tap="goNavbarLite" class="uni-btn">
</button> 跳转自定义导航栏页面
<button @tap="goCustomNavigation" class="uni-btn"> </button>
跳转设置状态栏页面 <!-- #endif -->
</button> <!-- #ifdef APP -->
</view> <button @tap="goCustomNavigation" class="uni-btn">
</template> 跳转设置状态栏页面
</button>
<script> <!-- #endif -->
import { state, setLifeCycleNum } from '@/store/index.uts' </view>
</template>
export default {
methods: { <script>
setNavigationBarColor1() { import { state, setLifeCycleNum } from '@/store/index.uts'
uni.setNavigationBarColor({
frontColor: '#ffffff', export default {
backgroundColor: '#00ff00', methods: {
success: () => { setNavigationBarColor1() {
console.log('setNavigationBarColor success') uni.setNavigationBarColor({
this.setLifeCycleNum(state.lifeCycleNum + 1) frontColor: '#ffffff',
}, backgroundColor: '#00ff00',
fail: () => { success: () => {
console.log('setNavigationBarColor fail') console.log('setNavigationBarColor success')
this.setLifeCycleNum(state.lifeCycleNum - 1) this.setLifeCycleNum(state.lifeCycleNum + 1)
}, },
complete: () => { fail: () => {
console.log('setNavigationBarColor complete') console.log('setNavigationBarColor fail')
this.setLifeCycleNum(state.lifeCycleNum + 1) this.setLifeCycleNum(state.lifeCycleNum - 1)
} },
}) complete: () => {
}, console.log('setNavigationBarColor complete')
setNavigationBarColor2() { this.setLifeCycleNum(state.lifeCycleNum + 1)
uni.setNavigationBarColor({ }
frontColor: '#000000', })
backgroundColor: '#ff0000', },
success: () => { setNavigationBarColor2() {
console.log('setNavigationBarColor success') uni.setNavigationBarColor({
this.setLifeCycleNum(state.lifeCycleNum + 1) frontColor: '#000000',
}, backgroundColor: '#ff0000',
fail: () => { success: () => {
console.log('setNavigationBarColor fail') console.log('setNavigationBarColor success')
this.setLifeCycleNum(state.lifeCycleNum - 1) this.setLifeCycleNum(state.lifeCycleNum + 1)
}, },
complete: () => { fail: () => {
console.log('setNavigationBarColor complete') console.log('setNavigationBarColor fail')
this.setLifeCycleNum(state.lifeCycleNum + 1) this.setLifeCycleNum(state.lifeCycleNum - 1)
} },
}) complete: () => {
}, console.log('setNavigationBarColor complete')
// 自动化测试 this.setLifeCycleNum(state.lifeCycleNum + 1)
getLifeCycleNum() : number { }
return state.lifeCycleNum })
}, },
// 自动化测试 // 自动化测试
setLifeCycleNum(num : number) { getLifeCycleNum() : number {
setLifeCycleNum(num) return state.lifeCycleNum
}, },
goNavbarLite() { // 自动化测试
uni.navigateTo({ setLifeCycleNum(num : number) {
url: '/pages/template/navbar-lite/navbar-lite' setLifeCycleNum(num)
}) },
}, goNavbarLite() {
goCustomNavigation(){ uni.navigateTo({
uni.navigateTo({ url: '/pages/template/navbar-lite/navbar-lite'
url: '/pages/API/set-navigation-bar-color/set-navigation-bar-color-custom-navigation' })
}) },
} goCustomNavigation() {
}, uni.navigateTo({
} url: '/pages/API/set-navigation-bar-color/set-navigation-bar-color-custom-navigation'
})
}
},
}
</script> </script>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册