微信小程序 slot 不显示

问题:创建组件,使用带名字的slot,页面调用组件使用slot不显示

微信小程序 slot 不显示_第1张图片

源码:

组件xml



    
    
      
        -
        
        +
      
      
    
  

JS:根据条件判断是否使用slot

Component({
  properties: {
    custBottom: {type: Boolean, value: false}
  },
 
  data: {},
  lifetimes: {
    attached() {
      console.log(">>> 被页面调用", this.data)
    }
  },
  methods: {
  }
});

 页面调用

 
    
      TEST
    

    

  

解决:

组件加上多slot配置,置为true

options: {
  multipleSlots: true
},

 修改:

Component({
  properties: {
    custBottom: {type: Boolean, value: false}
  },
options: {
  multipleSlots: true //增加此配置slot
},
 
  data: {},
  lifetimes: {
    attached() {
      console.log(">>> 被页面调用", this.data)
    }
  },
  methods: {
  }
});

效果:slot出来了。

微信小程序 slot 不显示_第2张图片

你可能感兴趣的:(小程序,apache)