提交 3c2c054f 编写于 作者: H hdx

unicloud-db-contacts: 在 onLoad 中加载数据以加快显示

上级 8635bc49
<template>
<scroll-view class="page">
<unicloud-db ref="udb" v-slot:default="{data, loading, error}" :collection="collection" :where="where"
loadtime="manual" page-data="replace">
page-data="replace">
<view v-if="error!=null" class="error">{{error.errMsg}}</view>
<view v-if="loading" class="loading">正在加载...</view>
<view v-if="data.length>0">
......@@ -37,13 +37,14 @@
export default {
data() {
return {
collection: COLLECTION_NAME,
collection: '',
where: '',
$whereID: '',
$uniCloudElement: null as UniCloudDBElement | null
}
},
onLoad(options : Map<string, string>) {
this.collection = COLLECTION_NAME;
this.$whereID = options.get('id') as string;
this.where = `_id=='${this.$whereID}'`;
},
......@@ -57,7 +58,6 @@
},
onReady() {
this.$uniCloudElement = this.$refs['udb'] as UniCloudDBElement
this.$uniCloudElement!.loadData()
},
methods: {
displayGender(value : number | null) : string {
......@@ -73,7 +73,7 @@
url: './edit?id=' + id
})
},
onDataChange(id : string) {
onDataChange(_ : string) {
this.$uniCloudElement!.loadData()
}
}
......
<template>
<scroll-view class="scroll-view" :scroll-y="true">
<unicloud-db ref="udb" v-slot:default="{data, loading, error}" :collection="collection" :where="where"
page-data="replace" loadtime="manual">
page-data="replace">
<view v-if="error!=null" class="error">{{error.errMsg}}</view>
<view v-if="loading" class="loading">正在加载...</view>
<form v-if="data.length>0" @submit="onFormSubmit">
......@@ -46,7 +46,7 @@
export default {
data() {
return {
collection: COLLECTION_NAME,
collection: '',
where: '',
genderList: GenderList as GenderType[],
$whereID: '',
......@@ -54,12 +54,12 @@
}
},
onLoad(options : Map<string, string>) {
this.collection = COLLECTION_NAME;
this.$whereID = options.get('id') as string;
this.where = `_id=='${this.$whereID}'`;
},
onReady() {
this.$uniCloudElement = this.$refs['udb'] as UniCloudDBElement
this.$uniCloudElement!.loadData()
},
methods: {
onFormSubmit: function (e : FormSubmitEvent) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册