原因:子組件需要調用父組件傳過來的數據,如果這個數據是異步從接口里取的,那這個組件在任何生命周期里都取不到,而應該在接口調取后取到。
需要在msg拿到值后才調用組件,然后你在生命周期created
里面取到值了。
解決:
父組件:
<parent v-if='parent_msg' :message="{parent_msg, 'index'}"></parent>
子組件:
<child>{{this.message.parent_msg}}</child>
<script>
export default {
props: ["message"]
}
</script>