index.ts 942 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. Component({
  2. externalClasses: ['custom-class'],
  3. options: {
  4. multipleSlots: true,
  5. },
  6. properties: {
  7. // 圆角大小
  8. round: {
  9. type: String,
  10. value: 'none',
  11. },
  12. // 外边距
  13. margin: {
  14. type: Boolean,
  15. value: false,
  16. }
  17. },
  18. data: {
  19. styles: '',
  20. },
  21. methods: {
  22. },
  23. attached() {
  24. const styles: string[] = []
  25. if (this.data.margin) {
  26. styles.push('margin-left:24rpx')
  27. styles.push('margin-right:24rpx')
  28. }
  29. switch (this.data.round) {
  30. case 'normal': {
  31. styles.push('border-radius:20rpx')
  32. break;
  33. }
  34. case 'small': {
  35. styles.push('border-radius:10rpx')
  36. break;
  37. }
  38. }
  39. this.setData({
  40. styles: styles.join(';')
  41. })
  42. }
  43. })