index.js 695 B

1234567891011121314151617181920212223242526272829303132333435
  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. lifetimes: {
  21. attached: function () {
  22. getApp().globalData.Language.getLanguagePackage(this)
  23. }
  24. },
  25. methods: {
  26. /* 改变开关状态 */
  27. changeSwitch() {
  28. let showAll = !this.data.switch;
  29. this.setData({
  30. switch: showAll
  31. })
  32. this.triggerEvent("callBack", showAll)
  33. }
  34. }
  35. })