index.ts 876 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // components/w-radio/index.ts
  2. Component({
  3. options: {
  4. multipleSlots: true,
  5. styleIsolation: "shared"
  6. },
  7. /**
  8. * 组件的属性列表
  9. */
  10. properties: {
  11. value: {
  12. type: [String, Number] as any,
  13. value: '',
  14. observer: '_value'
  15. },
  16. /** 选项值 */
  17. options: {
  18. type: Array,
  19. value: []
  20. },
  21. /** 排列方向,可选值为 vertical horizontal */
  22. direction: {
  23. type: String,
  24. value: "horizontal",
  25. },
  26. },
  27. /**
  28. * 组件的初始数据
  29. */
  30. data: {
  31. innerValue: ''
  32. },
  33. /**
  34. * 组件的方法列表
  35. */
  36. methods: {
  37. onCheckChange(event: { detail: any }) {
  38. const value = event.detail
  39. this.setData({
  40. value: value
  41. })
  42. this.triggerEvent('input', value)
  43. },
  44. _value() {
  45. this.setData({
  46. innerValue: this.data.value
  47. })
  48. }
  49. }
  50. })