美文网首页
小程序组件

小程序组件

作者: 一枚小菜 | 来源:发表于2020-07-12 15:38 被阅读0次

组件js

Component({
  properties: {
    // 传值从调用的组件传值过来
    show: {
      type: Boolean, // type 类型
      value: false // 默认类型
    },
    title: {
      type: String, // type 类型
      value: "具体内容" // 默认类型
    },
  },
  // 在组件需要方法的时候
  methods: {
    _noSure() {
      this.triggerEvent("noSure")
      
    },
    _sure() {
      this.triggerEvent("sure")
    },
    showsFalse() {
      this.setData({
        show: false
      })
    },
    no() {

    }
  }
})

组件json

{
  "component": true
}

使用组件

<alert-select title='{{showTitle}}' bindnoSure='noSure' bindsure='sure' show='{{show}}'>
</alert-select>

引用

  "usingComponents": {
    "x-scroll-view": "/components/x-scroll-view/index",
    "alert-select": "/components/alert-select/index"
  },

相关文章

网友评论

      本文标题:小程序组件

      本文链接:https://www.haomeiwen.com/subject/hzgacktx.html