微信小程序组件传参

微信小程序组件传参

1.父组件。

  .json文件

"usingComponents": {
    "nav-bar": "/components/navBar/navBar"
  },
  "navigationStyle": "custom" // 如果是头部自定义 需要此设置

  .wxml文件

<nav-bar title="我的"></nav-bar>  // 传参title  引号中如果是data 数据 需要用 {{}}括起来

2.子组件

  .json文件

"component": true,

  .js文件

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    title: {
      type: String
    }
  },
  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {

  }
})

  

posted @ 2020-11-17 18:26  我起飞啦!呜呜呜呜!  阅读(173)  评论(0)    收藏  举报