首页 新闻 会员 周边

mpvue 小程序 封装的子组件的data无法显示,且生命周期函数完全不执行

0
[已关闭问题] 关闭于 2019-03-02 14:49

//子组件的代码
<template>
<div>
<div>
{{sd}}
</div>
<div>
222
</div>
<div>
{{msg_datas}}
</div>
</div>
</template>
<script>
export default {
data(){
return {
sd: 'dsd'
}
},

props:{
msg_datas:String
},
onShow(){
console.log("----")
}
,
created(){
console.log("----")
}
// props: {
// msg_datas: {
// type: String
// }
// },
}
</script>

<style>
.title{
text-align: center;
color: white;
margin-left:15px;
background-color:#FF3030;
height: 28px;
border-radius: 10px 0 0 10px ;
}
.center{
text-align: center;
height: 27px;
background-color:#CDCDB4
}
.more{
color: white;
text-align: center;
background-color:#FFA54F;
height: 28px;
border-radius: 0 10px 10px 0 ;
}
.container2{
height: 26px;
}
.label{
width: 100px;
width: 30px;
}
.swiper{
width: 100px;
width: 30px;
}
</style>

主组件引用截图:

陈chenchenhehehehe的主页 陈chenchenhehehehe | 初学一级 | 园豆:26
提问于:2019-03-02 13:49
< >
分享
所有回答(1)
0

我也遇到和楼主一样的情况,请问楼主后来怎么解决得呢

小白白呢 | 园豆:202 (菜鸟二级) | 2019-03-20 11:34

我是弄了大半天才解决这个问题,我这里的原因是父组件中以前有个components:{},然后自己在引入子组件的时候没注意,又写了个components:{}...一不小心犯下的错折腾了大半天,内心一万个草泥马在奔腾

支持(2) 反对(0) 小白白呢 | 园豆:202 (菜鸟二级) | 2019-03-20 15:11

@小白白呢: 就是这样的,,,,components没写入引用的组件

支持(0) 反对(0) 陈chenchenhehehehe | 园豆:26 (初学一级) | 2019-03-20 21:07
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册