123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <template>
- <page-head title="getCurrentPages"></page-head>
- <view class="uni-padding-wrap">
- <button class="btn btn-get-page-style" type="default" @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>
- <text class="page-style">当前 PageStyle</text>
- <text class="page-style-value">{{pageStyleText}}</text>
- <text class="status">状态:</text>
- <view class="status-list">
- <text>enablePullDownRefresh: {{enablePullDownRefreshStatus}}</text>
- </view>
- <text class="tips">当前版本仅支持设置属性 enablePullDownRefresh</text>
- </view>
- </template>
- <script>
- class Page {
- constructor(public route : string) {
- }
- }
- export default {
- data() {
- return {
- checked: false,
- pages: [] as Page[],
- currentPageStyle: {} as UTSJSONObject,
- // TODO
- enablePullDownRefreshStatus: true
- }
- },
- computed: {
- pageStyleText() : string {
- return JSON.stringify(this.currentPageStyle)
- }
- },
- onLoad() {
- const pages = getCurrentPages();
- const currentPage = pages[pages.length - 1];
- this.currentPageStyle = currentPage.getPageStyle();
- this.enablePullDownRefreshStatus = this.currentPageStyle["enablePullDownRefresh"] as boolean
- },
- onPullDownRefresh() {
- setTimeout(() => {
- uni.stopPullDownRefresh()
- }, 3000)
- },
- methods: {
- getPageStyle() {
- const pages = getCurrentPages();
- const currentPage = pages[pages.length - 1];
- this.currentPageStyle = currentPage.getPageStyle();
- },
- setPageStyle(enable : boolean) {
- // 目前仅支持 enablePullDownRefresh
- const pages = getCurrentPages();
- const currentPage = pages[pages.length - 1];
- currentPage.setPageStyle({
- enablePullDownRefresh: enable
- });
- this.enablePullDownRefreshStatus = enable
- },
- startPullDownRefresh() {
- uni.startPullDownRefresh()
- }
- },
- }
- </script>
- <style>
- .btn {
- margin-top: 10px;
- }
- .page-style {
- margin-top: 15px;
- }
- .page-style-value {
- margin-top: 5px;
- padding: 5px;
- background-color: #fff;
- width: 100%;
- /* #ifdef WEB */
- overflow-wrap: break-word;
- /* #endif */
- }
- .status {
- margin-top: 20px;
- }
- .status-list {
- margin-top: 5px;
- }
- .tips {
- font-size: 12px;
- margin-top: 15px;
- opacity: .8;
- }
- </style>
|