[Improvement] Popup: support lazy render (#1138)

This commit is contained in:
neverland
2018-05-23 11:01:27 +08:00
committed by GitHub
parent 7f10d99d3d
commit cb992ce979
14 changed files with 223 additions and 49 deletions
+17 -1
View File
@@ -1,6 +1,6 @@
<template>
<transition :name="currentTransition">
<div v-show="value" :class="b({ [position]: position })">
<div v-if="inited || !lazyRender" v-show="value" :class="b({ [position]: position })">
<slot />
</div>
</transition>
@@ -17,6 +17,10 @@ export default create({
props: {
transition: String,
lazyRender: {
type: Boolean,
default: true
},
overlay: {
type: Boolean,
default: true
@@ -31,10 +35,22 @@ export default create({
}
},
data() {
return {
inited: this.value
};
},
computed: {
currentTransition() {
return this.transition || (this.position === '' ? 'van-fade' : `popup-slide-${this.position}`);
}
},
watch: {
value() {
this.inited = this.inited || this.value;
}
}
});
</script>