需要引入的组件为: tabBar
引入的页面为: index
1.在需要引入的页面对应的index.json文件中进行引入
{
'usingComponents': {
'tab-bar':'/components/tabBar/tabBar'
}
}
2.在需要使用的页面的index.wxml文件内进行使用
<tab-bar name='我是传递的数据'></tab-bar>
3.接受传递过来的参数 在被引入组件的tabBar.js的properties进行接收
Component({
properties: {
name:{
type: String,
value: undefined
},
},
})
4.使用接收到的参数 在tabBar.wxml内使用
<text> tabBar {{ name }} </text>
本文介绍了如何在React项目中通过index.json引入tabBar组件,并展示如何在index.wxml中使用它。重点讲解了如何在tabBar.js中接收并处理来自index页面传递的参数,以及在tabBar.wxml中显示该参数的应用过程。
4441

被折叠的 条评论
为什么被折叠?



