index.js 581 B

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