button-group.js 837 B

1234567891011121314151617181920212223242526272829303132333435
  1. import TComponent from '../common/component';
  2. import config from '../common/config';
  3. import { canIUseFormFieldButton } from '../common/version';
  4. const { prefix } = config;
  5. const name = `${prefix}-button-group`;
  6. TComponent({
  7. behaviors: canIUseFormFieldButton() ? ['wx://form-field-button'] : [],
  8. properties: {
  9. type: {
  10. type: String,
  11. value: 'default',
  12. },
  13. },
  14. data: {
  15. className: '',
  16. },
  17. observers: {
  18. type() {
  19. this.setClass();
  20. },
  21. },
  22. lifetimes: {
  23. attached() {
  24. this.setClass();
  25. },
  26. },
  27. methods: {
  28. setClass() {
  29. const classList = [`${name}`, `${name}--${this.data.type}`];
  30. this.setData({
  31. className: classList.join(' '),
  32. });
  33. },
  34. },
  35. });