插槽

插槽 SLOT 基于动态设置的思想

  • 单一插槽

  • 插槽的定义

  • <view>head</view>
  • <slot/>
  • <view>tag</view>
  • 插槽的使用

  • <my-slot> <iframe>content<iframe> </my-slot>
  • 注意: iframe 对应的必须是插槽存在的位置,如果对应的slot不存在,则不会渲染该iframe

多插槽

slot 的name属性

  • <slot name='slot_name'>

开启多插槽功能

  • 在组件的components 添加 options
    -Component({ options:{ multipleSlots:true }}

插槽的赋值

  • <button slot='slot_name'>

组件的component 相关属性

  • properties 传递数据
  • data 初始化数据
  • methods 操作数据的函数
  • options 配置&选项
  • externalClasses 额外样式
  • observers 数据监听器 语法: key:function(newValue){...}
  • pageLivetimes 监听页面声明周期函数 show(),hide(),resize()
  • lifetimes 监听组件生命周期函数 created(),attached(),ready(),moved(),detached()

组件的生命周期函数

  • 同时监听 组件自身 和 页面 的生命周期
posted @ 2020-05-19 10:09  insense  阅读(180)  评论(0)    收藏  举报