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

refactor(getCurrentPages): 移除类型警告

上级 a3802864
<template> <template>
<!-- #ifdef APP --> <!-- #ifdef APP -->
<scroll-view class="page-scroll-view"> <scroll-view class="page-scroll-view">
<!-- #endif --> <!-- #endif -->
<view> <view>
<page-head title="getCurrentPages"></page-head> <page-head title="getCurrentPages"></page-head>
<view class="uni-padding-wrap"> <view class="uni-padding-wrap">
...@@ -9,45 +9,78 @@ ...@@ -9,45 +9,78 @@
<view v-if="pages.length" style="padding: 15px 0px"> <view v-if="pages.length" style="padding: 15px 0px">
<text>当前页面栈中 {{ pages.length }} 个页面,列表如下:</text> <text>当前页面栈中 {{ pages.length }} 个页面,列表如下:</text>
<template v-for="(page, index) in pages" :key="page.route"> <template v-for="(page, index) in pages" :key="page.route">
<text style="margin-top: 5px">index: {{ index }}, route: {{ page.route }}</text> <text style="margin-top: 5px"
>index: {{ index }}, route: {{ page.route }}</text
>
</template> </template>
</view> </view>
<button class="uni-common-mt" @click="check$page">check $page</button> <button class="uni-common-mt" @click="check$page">check $page</button>
<button class="uni-common-mt" @click="checkGetParentPage">check getParentPage</button> <button class="uni-common-mt" @click="checkGetParentPage">
<button class="uni-common-mt" @click="checkGetDialogPages">check getDialogPages</button> check getParentPage
<button id="check-get-element-by-id-btn" class="uni-common-mt" @click="checkGetElementById">check </button>
getElementById</button> <button class="uni-common-mt" @click="checkGetDialogPages">
<button class="uni-common-mt" @click="checkGetAndroidView">check getAndroidView</button> check getDialogPages
</button>
<button
id="check-get-element-by-id-btn"
class="uni-common-mt"
@click="checkGetElementById"
>
check getElementById
</button>
<button class="uni-common-mt" @click="checkGetAndroidView">
check getAndroidView
</button>
</view> </view>
<page-head title="currentPageStyle"></page-head> <page-head title="currentPageStyle"></page-head>
<template v-for="(item, index) in PageStyleArray"> <template v-for="(item, index) in PageStyleArray">
<view class="page-style-item" v-if="currentPageStyle[item.key]!=null" :key="index"> <view
class="page-style-item"
v-if="currentPageStyle[item.key] != null"
:key="index"
>
<view class="item-text"> <view class="item-text">
<text class="item-text-key">{{item.key}}:</text> <text class="item-text-key">{{ item.key }}:</text>
<text class="item-text-value">{{currentPageStyle[item.key]}}</text> <text class="item-text-value">{{
currentPageStyle[item.key]
}}</text>
</view> </view>
<view class="set-value" v-if="item.type == 'boolean'"> <view class="set-value" v-if="item.type == 'boolean'">
<switch :checked="currentPageStyle.getBoolean(item.key)" <switch
@change="switchChange(item.key, $event as UniSwitchChangeEvent)"> :checked="currentPageStyle.getBoolean(item.key)"
@change="switchChange(item.key, $event as UniSwitchChangeEvent)"
>
</switch> </switch>
</view> </view>
<view class="set-value" v-else-if="item.type == 'number'"> <view class="set-value" v-else-if="item.type == 'number'">
<slider :value="currentPageStyle.getNumber(item.key)" :show-value="true" <slider
@change="sliderChange(item.key, $event as UniSliderChangeEvent)" /> :value="currentPageStyle.getNumber(item.key)"
:show-value="true"
@change="sliderChange(item.key, $event as UniSliderChangeEvent)"
/>
</view> </view>
<view class="set-value" v-else-if="item.type == 'string'"> <view class="set-value" v-else-if="item.type == 'string'">
<radio-group class="radio-set-value" @change="radioChange(item.key, $event as RadioGroupChangeEvent)"> <radio-group
<radio class="radio-value" v-for="(item2, index2) in item.value" :key="index2" :value="item2">{{item2}} class="radio-set-value"
@change="radioChange(item.key, $event as RadioGroupChangeEvent)"
>
<radio
class="radio-value"
v-for="(item2, index2) in item.value"
:key="index2"
:value="item2"
>{{ item2 }}
</radio> </radio>
</radio-group> </radio-group>
</view> </view>
</view> </view>
</template> </template>
<button style='margin: 10px;' @click="goSetDisablePullDownRefresh">go set disable pullDownRefresh</button> <button style="margin: 10px" @click="goSetDisablePullDownRefresh">
go set disable pullDownRefresh
</button>
</view> </view>
<!-- #ifdef APP --> <!-- #ifdef APP -->
</scroll-view> </scroll-view>
<!-- #endif --> <!-- #endif -->
</template> </template>
...@@ -141,14 +174,16 @@ ...@@ -141,14 +174,16 @@
check$page() : boolean { check$page() : boolean {
const page = this.getCurrentPage() const page = this.getCurrentPage()
let res = this.$page === page let res = this.$page === page
if (this.testing) { if (this.testing && res) {
res = res && page.options.get('test') == '123' res = page.options.get('test') == '123'
// #ifdef WEB if (res) {
res = page.route == '/pages/API/get-current-pages/get-current-pages' // #ifdef WEB
// #endif res = page.route == '/pages/API/get-current-pages/get-current-pages'
// #ifndef WEB // #endif
res = page.route == 'pages/API/get-current-pages/get-current-pages' // #ifndef WEB
// #endif res = page.route == 'pages/API/get-current-pages/get-current-pages'
// #endif
}
} }
console.log('check $page', res) console.log('check $page', res)
return res return res
...@@ -198,43 +233,43 @@ ...@@ -198,43 +233,43 @@
</script> </script>
<style> <style>
.page { .page {
flex: 1; flex: 1;
padding: 10px; padding: 10px;
} }
.page-style { .page-style {
margin-top: 15px; margin-top: 15px;
} }
.page-style-item { .page-style-item {
padding: 10px; padding: 10px;
margin-top: 10px; margin-top: 10px;
background-color: #ffffff; background-color: #ffffff;
border-radius: 5px; border-radius: 5px;
} }
.item-text { .item-text {
flex-direction: row; flex-direction: row;
} }
.item-text-key { .item-text-key {
font-weight: bold; font-weight: bold;
} }
.item-text-value { .item-text-value {
margin-left: 5px; margin-left: 5px;
} }
.set-value { .set-value {
margin-top: 10px; margin-top: 10px;
} }
.radio-set-value { .radio-set-value {
flex-direction: row; flex-direction: row;
} }
.radio-value { .radio-value {
margin-left: 10px; margin-left: 10px;
} }
</style> </style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册