子组件
index.js
Component({
props: {
classify_seleted: {
type: String,
value: ""
},
onTapClassify: () => {},
},
methods: {
tapClassify(e){
this.props.onTapClassify(e);
}
},
});
index.json
{
"component": true,
"usingComponents": {}
}
index.axml
<view onTap="tapClassify"></view>
父组件
index.js
const app = getApp();
Page({
tapClassify() {
console.log('子组件调用了');
},
});
index.json
{
"usingComponents": {
"zdy-components": "/pages/component/zdy-components"
}
}
index.axml
<zdy-components onTapClassify="tapClassify"></zdy-components>
网友评论