button.ts 525 B

12345678910111213141516171819202122
  1. // components/button/button.ts
  2. Component({
  3. behaviors: ['wx://form-field-button'],
  4. lifetimes: {
  5. attached() {
  6. const mode = this.data.block ? 'block' : 'line';
  7. const index = this.data.index;
  8. this.setData({
  9. src: `../../assets/bg/button-${mode}-${index}.bg.png`,
  10. className: this.data.block ? 'block' : `line-${index}`,
  11. })
  12. }
  13. },
  14. properties: {
  15. block: { type: Boolean, value: false },
  16. index: { type: Number, value: 1 },
  17. },
  18. data: {
  19. src: '',
  20. },
  21. methods: {}
  22. })