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

feat: setNavigationBarTitle 补充超长标题示例

上级 6fde3b0e
......@@ -16,11 +16,16 @@ describe("setNavigationBarColor", () => {
expect(lifeCycleNum).toBe(originLifeCycleNum);
});
it("setNavigationBarTitle", async () => {
await page.callMethod("setNavigationBarTitle");
it("setNavigationBarNewTitle", async () => {
await page.callMethod("setNavigationBarNewTitle");
const image = await program.screenshot();
expect(image).toMatchImageSnapshot();
const lifeCycleNum = await page.callMethod("getLifeCycleNum");
expect(lifeCycleNum - originLifeCycleNum).toBe(2);
});
it("setNavigationBarLongTitle", async () => {
await page.callMethod("setNavigationBarLongTitle");
const image = await program.screenshot();
expect(image).toMatchImageSnapshot();
});
});
......@@ -2,8 +2,11 @@
<view>
<page-head title="setNavigationBarTitle"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<button @tap="setNavigationBarTitle" class="uni-btn">
设置当前页面的标题为 {{ newTitle }}
<button @tap="setNavigationBarNewTitle" class="uni-btn">
设置当前页面标题为: {{ newTitle }}
</button>
<button @tap="setNavigationBarLongTitle" class="uni-btn">
设置超长标题
</button>
</view>
</view>
......@@ -15,11 +18,12 @@ import { state, setLifeCycleNum } from '@/store/index.uts'
export default {
data(){
return {
newTitle: 'new title'
newTitle: 'new title',
longTitle: 'long title long title long title long title long title long title long title long title long title long title'
}
},
methods: {
setNavigationBarTitle() {
setNavigationBarNewTitle() {
uni.setNavigationBarTitle({
title: this.newTitle,
success() {
......@@ -27,7 +31,7 @@ export default {
this.setLifeCycleNum(state.lifeCycleNum + 1)
},
fail() {
console.log('setNavigationBarTitle success')
console.log('setNavigationBarTitle fail')
this.setLifeCycleNum(state.lifeCycleNum - 1)
},
complete() {
......@@ -36,6 +40,20 @@ export default {
}
})
},
setNavigationBarLongTitle() {
uni.setNavigationBarTitle({
title: this.longTitle,
success() {
console.log('setNavigationBarTitle success')
},
fail() {
console.log('setNavigationBarTitle fail')
},
complete() {
console.log('setNavigationBarTitle complete')
}
})
},
// 自动化测试
getLifeCycleNum(): number {
return state.lifeCycleNum
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册