[英]vue props passing from parent component to child
我有一个容器组件,里面有一个导航栏组件。 我在 beforeCreate 中调用了 api,然后在此处设置变量,并将它们设置为 vue 'state'(数据),然后将它们作为道具传递给导航栏组件。 但是,这些都没有出现。 我在这里做错了什么?
<template>
<Navbar :title='title' />
<template>
<script>
export default{
name:'example',
data(){
return{
title:''
};
},
beforeCreate: function(){
axios.post('')
.then(response => {
this.title = response.title
})
}
}
</script>
我已经控制台记录了来自 api 的响应数据,所以我知道它正在正确生成数据。 我还在已安装的生命周期中控制台记录了数据变量“标题”,它有数据。 但是导航栏的道具仍然是空的。
beforeCreate在数据观察之前被调用。 使用beforeMount重试
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.