Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
feb27aed
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6005
Star
91
Fork
164
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
feb27aed
编写于
11月 02, 2023
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: setNavigationBarTitle 补充超长标题示例
上级
6fde3b0e
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
30 addition
and
7 deletion
+30
-7
pages/API/set-navigation-bar-title/set-navigation-bar-title.test.js
...set-navigation-bar-title/set-navigation-bar-title.test.js
+7
-2
pages/API/set-navigation-bar-title/set-navigation-bar-title.uvue
...PI/set-navigation-bar-title/set-navigation-bar-title.uvue
+23
-5
未找到文件。
pages/API/set-navigation-bar-title/set-navigation-bar-title.test.js
浏览文件 @
feb27aed
...
@@ -16,11 +16,16 @@ describe("setNavigationBarColor", () => {
...
@@ -16,11 +16,16 @@ describe("setNavigationBarColor", () => {
expect
(
lifeCycleNum
).
toBe
(
originLifeCycleNum
);
expect
(
lifeCycleNum
).
toBe
(
originLifeCycleNum
);
});
});
it
(
"
setNavigationBarTitle
"
,
async
()
=>
{
it
(
"
setNavigationBar
New
Title
"
,
async
()
=>
{
await
page
.
callMethod
(
"
setNavigationBarTitle
"
);
await
page
.
callMethod
(
"
setNavigationBar
New
Title
"
);
const
image
=
await
program
.
screenshot
();
const
image
=
await
program
.
screenshot
();
expect
(
image
).
toMatchImageSnapshot
();
expect
(
image
).
toMatchImageSnapshot
();
const
lifeCycleNum
=
await
page
.
callMethod
(
"
getLifeCycleNum
"
);
const
lifeCycleNum
=
await
page
.
callMethod
(
"
getLifeCycleNum
"
);
expect
(
lifeCycleNum
-
originLifeCycleNum
).
toBe
(
2
);
expect
(
lifeCycleNum
-
originLifeCycleNum
).
toBe
(
2
);
});
});
it
(
"
setNavigationBarLongTitle
"
,
async
()
=>
{
await
page
.
callMethod
(
"
setNavigationBarLongTitle
"
);
const
image
=
await
program
.
screenshot
();
expect
(
image
).
toMatchImageSnapshot
();
});
});
});
pages/API/set-navigation-bar-title/set-navigation-bar-title.uvue
浏览文件 @
feb27aed
...
@@ -2,8 +2,11 @@
...
@@ -2,8 +2,11 @@
<view>
<view>
<page-head title="setNavigationBarTitle"></page-head>
<page-head title="setNavigationBarTitle"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-padding-wrap uni-common-mt">
<button @tap="setNavigationBarTitle" class="uni-btn">
<button @tap="setNavigationBarNewTitle" class="uni-btn">
设置当前页面的标题为 {{ newTitle }}
设置当前页面标题为: {{ newTitle }}
</button>
<button @tap="setNavigationBarLongTitle" class="uni-btn">
设置超长标题
</button>
</button>
</view>
</view>
</view>
</view>
...
@@ -15,11 +18,12 @@ import { state, setLifeCycleNum } from '@/store/index.uts'
...
@@ -15,11 +18,12 @@ import { state, setLifeCycleNum } from '@/store/index.uts'
export default {
export default {
data(){
data(){
return {
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: {
methods: {
setNavigationBarTitle() {
setNavigationBar
New
Title() {
uni.setNavigationBarTitle({
uni.setNavigationBarTitle({
title: this.newTitle,
title: this.newTitle,
success() {
success() {
...
@@ -27,7 +31,7 @@ export default {
...
@@ -27,7 +31,7 @@ export default {
this.setLifeCycleNum(state.lifeCycleNum + 1)
this.setLifeCycleNum(state.lifeCycleNum + 1)
},
},
fail() {
fail() {
console.log('setNavigationBarTitle
success
')
console.log('setNavigationBarTitle
fail
')
this.setLifeCycleNum(state.lifeCycleNum - 1)
this.setLifeCycleNum(state.lifeCycleNum - 1)
},
},
complete() {
complete() {
...
@@ -36,6 +40,20 @@ export default {
...
@@ -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 {
getLifeCycleNum(): number {
return state.lifeCycleNum
return state.lifeCycleNum
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录