需要引入的组件为: 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>