提交 e5380be0 编写于 作者: H hdx

feat(pageStyle): 新增示例及自动化测试

上级 9ef50c49
......@@ -361,7 +361,8 @@
{
"path": "pages/API/get-current-pages/get-current-pages",
"style": {
"navigationBarTitleText": "getCurrentPages"
"navigationBarTitleText": "getCurrentPages",
"enablePullDownRefresh": true
}
},
{
......
......@@ -6,9 +6,9 @@ describe('getCurrentPages', () => {
it('getCurrentPages', async () => {
// web 端等待应用首页加载完成
if (process.env.uniTestPlatformInfo.startsWith('web')) {
const waitTime = process.env.uniTestPlatformInfo.includes('safari')
? 5000
: 1000
const waitTime = process.env.uniTestPlatformInfo.includes('safari') ?
5000 :
1000
await new Promise((resolve) => {
setTimeout(() => {
resolve()
......@@ -24,4 +24,30 @@ describe('getCurrentPages', () => {
const data = await page.data()
expect(data.checked).toBe(true)
})
it('getPageStyle', async () => {
await changeData(page)
const btn = await page.$('.btn-get-page-style')
await btn.tap()
await page.waitFor(100)
const {
currentPageStyle
} = await page.data()
expect(currentPageStyle['enablePullDownRefresh']).toBe(true)
})
it('setPageStyle', async () => {
await changeData(page)
const btn = await page.$('.btn-set-page-style-0')
await btn.tap()
await page.waitFor(100)
const {
currentPageStyle
} = await page.data()
expect(currentPageStyle['enablePullDownRefresh']).toBe(false)
})
})
......@@ -8,6 +8,13 @@
<text style="margin-top: 5px">index: {{ index }}, route: {{ page.route }}</text>
</template>
</view>
<button class="btn btn-get-page-style" type="primary" @click="getPageStyle">getPageStyle</button>
<button class="btn btn-set-page-style-1" type="default" @click="setPageStyle(true)">setPageStyle(true)</button>
<button class="btn btn-set-page-style-0" type="default" @click="setPageStyle(false)">setPageStyle(false)</button>
<textarea class="textarea" :value="pageStyleText" :maxlength="-1" :auto-height="true"></textarea>
<text class="tips">
当前版本仅支持设置属性 enablePullDownRefresh
</text>
</view>
</template>
......@@ -22,8 +29,19 @@
return {
checked: false,
pages: [] as Page[],
currentPageStyle: {} as UTSJSONObject
}
},
computed: {
pageStyleText() : string {
return JSON.stringify(this.currentPageStyle)
}
},
onPullDownRefresh() {
setTimeout(() => {
uni.stopPullDownRefresh()
}, 3000)
},
methods: {
_getCurrentPages: function () {
this.pages.length = 0
......@@ -39,6 +57,43 @@
}
}
},
getPageStyle() {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
this.currentPageStyle = currentPage.$getPageStyle();
},
setPageStyle(epr : boolean) {
// 目前仅支持 enablePullDownRefresh
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
currentPage.$setPageStyle({
enablePullDownRefresh: epr
});
},
// getCurrentPage(): Page {
// const pages = getCurrentPages();
// const currentPage = pages[pages.length - 1];
// return currentPage;
// }
},
}
</script>
<style>
.btn {
margin-top: 10px;
}
.textarea {
margin-top: 5px;
padding: 5px;
background-color: #fff;
}
.tips {
font-size: 12px;
margin-top: 10px;
opacity: .8;
}
</style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册