sunday123

1、定义子组件

定义一个tip组件,在tip.json中将component设置为true

{
  "component": true,
  "usingComponents": {}
}

在tip.js中设置被调用方法

...
showMyTips(content) {
    console.log(content)
},
...

2、引入组件

在index页面引入组件

index.json

{
  "usingComponents": {
    "tip":"/components/tip"
  },
  "disableScroll":true
}

index.wxml

<tip id="tip"></tip>

3、调用方法

调用tip组件中的方法

index.js

this.selectComponent("#tip").showMyTips(\'哈哈哈\')

  

component

分类:

技术点:

相关文章: