index.js 501 B

12345678910111213141516171819202122
  1. Component({
  2. properties: {
  3. title: String,
  4. type: {
  5. type: String,
  6. value: "default", //默认类型 switch-开关
  7. },
  8. switchLabel: String, //开关标签,type==switch生效
  9. switch: Boolean, //开关属性值,type==switch生效
  10. callBack: Function
  11. },
  12. methods: {
  13. /* 改变开关状态 */
  14. changeSwitch() {
  15. let showAll = !this.data.switch;
  16. this.setData({
  17. switch: showAll
  18. })
  19. this.triggerEvent("callBack", showAll)
  20. }
  21. }
  22. })