子节点弹框时,激活子节点的高度,所以在子节点处绑定一个样式,display:table来激活高度,具体代码如下
<template>
<cube-popup type="my-popup" ref="myPopup">
<div class="scroll-list-wrap">
<cube-scroll
ref="scroll">
<div class="aa" :class={'abcd':ac}>
</div>
</cube-scroll>
</div>
</cube-popup>
<cube-button @click="showPopup('myPopup')">
Show Popup
</cube-button>
</template>
<script>
export default {
name: "Demo",
data(){
return{
ac:false
}
},
methods: {
showPopup(refId) {
const component = this.$refs[refId]
component.show()
setTimeout(() => {
component.hide()
}, 1000)
}
}
mounted(){
setTimeout(()=> {
// this.$refs['myPopup'].show();//激活弹框
this.ac=true
console.log(1);
}, 10)
}
}
<style>
.scroll-list-wrap {height: 350px}
.aa{width:100%; height:400px; background:red}
.abcd{display:table}
</style>