index.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // components/radioGroup/index.js
  2. Component({
  3. options: {
  4. lifetimes: true
  5. },
  6. /**
  7. * 组件的属性列表
  8. */
  9. properties: {
  10. //选项列表
  11. list: {
  12. type: Array,
  13. value: []
  14. },
  15. //显示的label的key
  16. labelKey: {
  17. type: String,
  18. value: null
  19. },
  20. //取值的value的key
  21. valueKey: {
  22. type: String,
  23. value: "id"
  24. },
  25. // 默认值
  26. value: null,
  27. chooseCss: {
  28. type: String,
  29. value: "radios"
  30. }
  31. // id:{
  32. // type:Number,
  33. // },
  34. },
  35. /**
  36. * 组件的初始数据
  37. */
  38. data: {},
  39. lifetimes: {
  40. attached() {
  41. const { value } = this.data;
  42. if (value != null) {
  43. this.triggerEvent("change", value);
  44. }
  45. }
  46. },
  47. /**
  48. * 组件的方法列表
  49. */
  50. methods: {
  51. onChange(e) {
  52. this.triggerEvent("change", e.detail);
  53. }
  54. }
  55. });