小程序compnent组件的使用

1.首先建立compment文件

2.在.json中写好配置

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

然后就像写页面一样把.wxml  .wxss .js写好 组件的封装就算完事了

3.使用的地方也需要写.json配置文件

.json中引入组件 并且给去一个名字 作为key值

{
  "usingComponents": {
    "uploadimage": "./component/uploadimage"
  },
  "navigationBarTextStyle": "black",
  "navigationBarTitleText": "练习页面",
  "navigationBarBackgroundColor": "#962927"
}

.wxml中直接调用封装的组件就可以了

<uploadimage/>

效果如下:

猜你喜欢

转载自blog.csdn.net/lee727n/article/details/106234319