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

refactor: 调整示例,兼容 UniPage

上级 78555572
......@@ -43,10 +43,10 @@
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
const currentPages = getCurrentPages()
const parentPage = this.getParentPage()!
const parentPage = this.$page.getParentPage()!
const grandParentPage = parentPage.getParentPage()
const dialogPages = parentPage.getDialogPages()
const dialogPage = this.$dialogPage!
const dialogPage = this.$page as UniDialogPage
if (
currentPages.length == 1 &&
grandParentPage == null &&
......@@ -126,7 +126,7 @@
},
closeThisDialog() {
uni.closeDialogPage({
dialogPage: this.$dialogPage,
dialogPage: this.$page as UniDialogPage,
success(res) {
console.log('closeThisDialog success', res)
// 自动化测试
......
......@@ -93,7 +93,7 @@
},
closeThisDialog() {
uni.closeDialogPage({
dialogPage: this.$dialogPage,
dialogPage: this.$page as UniDialogPage,
success(res) {
console.log('closeThisDialog success', res)
// 自动化测试
......
......@@ -112,14 +112,14 @@
getPageStyle() : UTSJSONObject {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
this.currentPageStyle = currentPage.$getPageStyle()
this.currentPageStyle = currentPage.getPageStyle()
return this.currentPageStyle;
},
setPageStyle(style : UTSJSONObject) {
console.log('setPageStyle:', style);
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
currentPage.$setPageStyle(style);
currentPage.setPageStyle(style);
},
goSetDisablePullDownRefresh() {
uni.navigateTo({
......
......@@ -44,13 +44,13 @@
getPageStyle() {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
this.currentPageStyle = currentPage.$getPageStyle();
this.currentPageStyle = currentPage.getPageStyle();
},
setPageStyle(enable : boolean) {
// 目前仅支持 enablePullDownRefresh
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
currentPage.$setPageStyle({
currentPage.setPageStyle({
enablePullDownRefresh: enable
});
this.enablePullDownRefreshStatus = enable
......
......@@ -16,10 +16,10 @@
changeColor() {
let pages = getCurrentPages()
let page = pages[pages.length - 1]
page.$setPageStyle({ "backgroundColorContent": this.isChange ? "" : "red" })
page.setPageStyle({ "backgroundColorContent": this.isChange ? "" : "red" })
this.isChange = !this.isChange
let pageJson = page.$getPageStyle()
let pageJson = page.getPageStyle()
this.currentBackgroundColorContent = pageJson["backgroundColorContent"]
}
}
......
......@@ -224,19 +224,16 @@ export const get_page_name = (routepath : string) : string => {
if (page.route != routepath) {
const pages = getCurrentPages()
// 如果传入路由与当前页面不同,则从页面栈找一个,如果找不到返回空
let page_now = pages.find((v) : boolean => {
if (v.route == routepath) {
return true;
}
return false
})
let page_now = pages.find((p): boolean => p.route == routepath)
if (page_now == null) {
return ''
}
page = page_now
// @ts-ignore
page = page_now.vm!
}
const pageStyle = page.$getPageStyle()
// @ts-ignore
const pageStyle = page.$page.getPageStyle()
const titleText = pageStyle['navigationBarTitleText'] ?? ''
return titleText as string
}
......@@ -251,7 +248,8 @@ export const get_page_vm = () : Page | null => {
}
let page = pages[pages.length - 1]
// TODO 正常来说,调用当前方法的地方只在 生命周期内,数组内最少会有一个页面,所以理论上是不存在获取不到的情况的
return page
// @ts-ignore
return page.vm
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册