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

feat: setNavigationBarTitle

上级 a4737498
......@@ -257,11 +257,17 @@
"navigationBarTitleText": "页面跳转"
}
},
{
"path": "pages/API/set-navigation-bar-color/set-navigation-bar-color",
"style": {
"navigationBarTitleText": "设置导航条颜色"
}
{
"path": "pages/API/set-navigation-bar-color/set-navigation-bar-color",
"style": {
"navigationBarTitleText": "设置导航条颜色"
}
},
{
"path": "pages/API/set-navigation-bar-title/set-navigation-bar-title",
"style": {
"navigationBarTitleText": "设置导航条标题"
}
},
{
"path": "pages/API/set-navigation-bar-color/set-custom-navigation-bar-color",
......@@ -1018,7 +1024,7 @@
},
{
"path" : "pages/API/install-apk/install-apk",
"style" :
"style" :
{
"navigationBarTitleText" : "install-apk",
"enablePullDownRefresh" : false
......
const CURRENT_PAGE_PATH =
"/pages/API/set-navigation-bar-title/set-navigation-bar-title";
describe("setNavigationBarColor", () => {
let page;
let originLifeCycleNum;
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);
const lifeCycleNum = await page.callMethod("getLifeCycleNum");
expect(lifeCycleNum).toBe(originLifeCycleNum);
});
it("setNavigationBarTitle", async () => {
await page.callMethod("setNavigationBarTitle");
const image = await program.screenshot();
expect(image).toMatchImageSnapshot();
const lifeCycleNum = await page.callMethod("getLifeCycleNum");
expect(lifeCycleNum - originLifeCycleNum).toBe(2);
});
});
<template>
<view>
<page-head title="setNavigationBarTitle"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<button @tap="setNavigationBarTitle" class="uni-btn">
设置当前页面的标题为 {{ newTitle }}
</button>
</view>
</view>
</template>
<script lang="uts">
import { state, setLifeCycleNum } from '@/store/index.uts'
export default {
data(){
return {
newTitle: 'new title'
}
},
methods: {
setNavigationBarTitle() {
uni.setNavigationBarTitle({
title: this.newTitle,
success() {
console.log('setNavigationBarTitle success')
this.setLifeCycleNum(state.lifeCycleNum + 1)
},
fail() {
console.log('setNavigationBarTitle success')
this.setLifeCycleNum(state.lifeCycleNum - 1)
},
complete() {
console.log('setNavigationBarTitle complete')
this.setLifeCycleNum(state.lifeCycleNum + 1)
}
})
},
// 自动化测试
getLifeCycleNum(): number {
return state.lifeCycleNum
},
// 自动化测试
setLifeCycleNum(num: number) {
setLifeCycleNum(num)
}
},
}
</script>
......@@ -97,12 +97,11 @@
url: 'navigator',
api: ["navigateTo", "reLaunch", "navigateBack", "redirectTo", "switchTab"]
},
/*
{
name: '设置导航条标题',
url: 'set-navigation-bar-title',
enable: false,
}, */
},
{
name: '设置导航条颜色',
url: 'set-navigation-bar-color',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册