码迷,mamicode.com
首页 > 其他好文 > 详细

子组件的使用

时间:2019-12-05 12:56:22      阅读:98      评论:0      收藏:0      [点我收藏+]

标签:gid   str   组件   bsp   ctrl   com   footer   lun   cart   

子组件的使用

.json中配置"usingComponents"字段,{"标签名": "子组件路径"}

"usingComponents": {
"x-blog-cart": "/components/blog-cart/blog-cart",
"x-blog-ctrl": "/components/blog-ctrl/blog-ctrl",
},
在.wxml中使用
 
 
<view class="detail-footer">
  <x-blog-ctrl
    iconfont="iconfont"
    icon-share="icon-share"
    icon-pinglun="icon-pinglun"
    blogId="{{blog._id}}"
  />
</view>
父组件给子组件传递样式:上面粉红色是部分
子组件接受(在Component(.js子组件有Component包裹) 中配置externalClasses属性):
//外部样式
externalClasses: [
‘iconfont‘,
‘icon-share‘,
‘icon-pinglun‘
],
注意:
iconfont="iconfont"
icon-share="icon-share"
icon-pinglun="icon-pinglun"
样式传递
由于有样式隔离,子组件想使用公共样式,需要传递
 

子组件的使用

标签:gid   str   组件   bsp   ctrl   com   footer   lun   cart   

原文地址:https://www.cnblogs.com/baixinL/p/11988456.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!