提交 8fe93144 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

refactor: onLoad 参数类型调整支持向下兼容

上级 3869946d
......@@ -9,9 +9,7 @@
<view v-if="pages.length" style="padding: 15px 0px">
<text>当前页面栈中 {{ pages.length }} 个页面,列表如下:</text>
<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>
</view>
<button class="uni-common-mt" @click="check$page">check $page</button>
......@@ -21,11 +19,7 @@
<button class="uni-common-mt" @click="checkGetDialogPages">
check getDialogPages
</button>
<button
id="check-get-element-by-id-btn"
class="uni-common-mt"
@click="checkGetElementById"
>
<button id="check-get-element-by-id-btn" class="uni-common-mt" @click="checkGetElementById">
check getElementById
</button>
<button class="uni-common-mt" @click="checkGetAndroidView">
......@@ -35,11 +29,7 @@
<page-head title="currentPageStyle"></page-head>
<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">
<text class="item-text-key">{{ item.key }}:</text>
<text class="item-text-value">{{
......@@ -47,30 +37,17 @@
}}</text>
</view>
<view class="set-value" v-if="item.type == 'boolean'">
<switch
:checked="currentPageStyle.getBoolean(item.key)"
@change="switchChange(item.key, $event as UniSwitchChangeEvent)"
>
<switch :checked="currentPageStyle.getBoolean(item.key)"
@change="switchChange(item.key, $event as UniSwitchChangeEvent)">
</switch>
</view>
<view class="set-value" v-else-if="item.type == 'number'">
<slider
:value="currentPageStyle.getNumber(item.key)"
:show-value="true"
@change="sliderChange(item.key, $event as UniSliderChangeEvent)"
/>
<slider :value="currentPageStyle.getNumber(item.key)" :show-value="true"
@change="sliderChange(item.key, $event as UniSliderChangeEvent)" />
</view>
<view class="set-value" v-else-if="item.type == 'string'">
<radio-group
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-group 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-group>
</view>
......@@ -108,7 +85,10 @@
return JSON.stringify(this.currentPageStyle)
}
},
onLoad() {
onLoad(options : OnLoadOptions) {
if (options instanceof UTSJSONObject) {
this.checked = true
}
this.getPageStyle();
},
onPullDownRefresh() {
......@@ -124,7 +104,7 @@
this.pages.length = 0
const pages = getCurrentPages()
this.pages.push(new Page(pages[0].route))
if (this.pages[0].route.includes('/tabBar/') || this.pages[0].route == '/') {
if (this.checked && (this.pages[0].route.includes('/tabBar/') || this.pages[0].route == '/')) {
this.checked = true
}
for (let i = 1; i < pages.length; i++) {
......@@ -175,7 +155,7 @@
const page = this.getCurrentPage()
let res = this.$page === page
if (this.testing && res) {
res = page.options.get('test') == '123'
res = page.options['test'] == '123'
if (res) {
// #ifdef WEB
res = page.route == '/pages/API/get-current-pages/get-current-pages'
......@@ -233,43 +213,43 @@
</script>
<style>
.page {
.page {
flex: 1;
padding: 10px;
}
}
.page-style {
.page-style {
margin-top: 15px;
}
}
.page-style-item {
.page-style-item {
padding: 10px;
margin-top: 10px;
background-color: #ffffff;
border-radius: 5px;
}
}
.item-text {
.item-text {
flex-direction: row;
}
}
.item-text-key {
.item-text-key {
font-weight: bold;
}
}
.item-text-value {
.item-text-value {
margin-left: 5px;
}
}
.set-value {
.set-value {
margin-top: 10px;
}
}
.radio-set-value {
.radio-set-value {
flex-direction: row;
}
}
.radio-value {
.radio-value {
margin-left: 10px;
}
}
</style>
......@@ -20,7 +20,7 @@
},
onLoad(options : OnLoadOptions) {
if (options['data'] != null) {
this.data = options['data'] as string
this.data = options['data']!
}
},
methods: {
......
......@@ -23,9 +23,9 @@
}
},
onLoad(event : OnLoadOptions) {
this.post_id = event["post_id"] as string ?? "";
this.cover = event["cover"] as string ?? "";
this.title = event["title"] as string ?? "";
this.post_id = event["post_id"] ?? "";
this.cover = event["cover"] ?? "";
this.title = event["title"] ?? "";
this.getDetail();
},
methods: {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册