应用v-if指令来动态创建子组件
子组件中:
<template> <div>{{value}}</div></template><script>export default { props: { value: { type: String } }}</script>
在父组件中:
<template> <div> <div v-if="viewReady"> <child v-bind:value=""/> </div> <div></template><script>export default { data() { return { viewReady: false } }, created() { this.getData() }, methods: { getData() { return new Promise(r=> { // request r() }).then(res => { this.viewReady = true }) } }}</script>