提交 9171cea3 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

feat(api): setNavigationBarColor

上级 1ca3f346
......@@ -171,6 +171,13 @@
"navigationBarTitleText": "页面跳转"
}
},
{
"path": "pages/API/set-navigation-bar-color/set-navigation-bar-color",
"style": {
"navigationBarTitleText": "设置导航条颜色"
}
},
{
"path": "pages/API/navigator/new-page/new-page-1",
"style": {
......@@ -671,23 +678,20 @@
"navigationBarTitleText": "电量"
}
},
{
"path" : "pages/CSS/border/complex-border/complex-border",
"style" :
{
"navigationBarTitleText": "border属性组合示例",
"enablePullDownRefresh": false
}
{
"path": "pages/CSS/border/complex-border/complex-border",
"style": {
"navigationBarTitleText": "border属性组合示例",
"enablePullDownRefresh": false
}
,{
"path" : "pages/template/scroll-fold-nav2/scroll-fold-nav2",
"style" :
{
},
{
"path": "pages/template/scroll-fold-nav2/scroll-fold-nav2",
"style": {
"navigationStyle": "custom"
}
}
],
}
}
],
"globalStyle": {
"pageOrientation": "portrait",
"navigationBarTitleText": "Hello uniapp x",
......
......@@ -72,10 +72,7 @@ export default {
},
pageScrollTo(){
uni.pageScrollTo({
scrollTop: 1200,
complete(res){
console.warn('pageScrollTo', res)
}
scrollTop: 1200
})
}
},
......
const CURRENT_PAGE_PATH =
'/pages/API/set-navigation-bar-color/set-navigation-bar-color'
describe('setNavigationBarColor', () => {
let page
let originLifeCycleNum
let lifeCycleNum
beforeAll(async () => {
page = await program.navigateTo(CURRENT_PAGE_PATH)
await page.waitFor(1000)
originLifeCycleNum = await page.callMethod('getLifeCycleNum')
})
afterAll(async () => {
await page.callMethod('setLifeCycleNum', originLifeCycleNum)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(originLifeCycleNum)
})
it('setNavigationBarColor1', async () => {
await page.callMethod('setNavigationBarColor1')
const image = await program.screenshot()
expect(image).toMatchImageSnapshot()
})
it('setNavigationBarColor2', async () => {
await page.callMethod('setNavigationBarColor2')
const image = await program.screenshot()
expect(image).toMatchImageSnapshot()
})
})
<template>
<view>
<page-head title="setNavigationBarColor"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<button @tap="setNavigationBarColor1" class="uni-btn">
设置导航条背景绿色,标题白色
</button>
<button @tap="setNavigationBarColor2" class="uni-btn">
设置导航条背景红色,标题黑色
</button>
</view>
</view>
</template>
<script lang="ts">
import { state, setLifeCycleNum } from '@/store/index.uts'
export default {
methods: {
setNavigationBarColor1() {
uni.setNavigationBarColor({
frontColor: '#ffffff',
backgroundColor: '#00ff00',
success() {
console.log('setNavigationBarColor success')
setLifeCycleNum(state.lifeCycleNum + 1)
},
fail() {
console.log('setNavigationBarColor success')
setLifeCycleNum(state.lifeCycleNum - 1)
},
complete() {
console.log('setNavigationBarColor success')
setLifeCycleNum(state.lifeCycleNum + 1)
}
})
},
setNavigationBarColor2() {
uni.setNavigationBarColor({
frontColor: '#000000',
backgroundColor: '#ff0000',
success() {
console.log('setNavigationBarColor success')
setLifeCycleNum(state.lifeCycleNum + 1)
},
fail() {
console.log('setNavigationBarColor success')
setLifeCycleNum(state.lifeCycleNum - 1)
},
complete() {
console.log('setNavigationBarColor success')
setLifeCycleNum(state.lifeCycleNum + 1)
}
})
},
// 自动化测试
getLifeCycleNum(): number {
return state.lifeCycleNum
},
// 自动化测试
setLifeCycleNum(num: number) {
setLifeCycleNum(num)
},
},
}
</script>
<style>
.direction-row {
flex-direction: row;
}
.label {
width: 190px;
}
</style>
......@@ -81,10 +81,14 @@
enable: false
},
{
name: "设置导航条",
name: "设置导航条标题",
url: "set-navigation-bar-title",
enable: false
},
},
{
name: "设置导航条颜色",
url: "set-navigation-bar-color",
},
{
name: "设置TabBar",
url: "set-tabbar",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册