button.wxml 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <button class="tui-btn-class tui-btn {{plain?'tui-'+type+'-outline':'tui-btn-'+(type || 'primary')}} {{wxs.getDisabledClass(disabled,type)}} {{wxs.getShapeClass(shape,plain)}} {{wxs.getShadowClass(type,shadow,plain)}}" hover-class="{{wxs.getHoverClass(disabled,type,plain)}}"
  2. style="width:{{width}};height:{{height}};line-height:{{height}};font-size:{{size}}rpx" loading="{{loading}}" disabled="{{disabled}}" bindtap="handleClick">
  3. <slot></slot>
  4. </button>
  5. <wxs module="wxs">
  6. module.exports = {
  7. getShadowClass: function(type, shadow, plain) {
  8. var className = '';
  9. if (shadow && type != 'white' && !plain) {
  10. className = 'tui-shadow-' + type;
  11. }
  12. return className;
  13. },
  14. getDisabledClass: function(disabled, type) {
  15. var className = '';
  16. if (disabled && type != 'white' && type != 'gray') {
  17. className = 'tui-dark-disabled';
  18. }
  19. return className;
  20. },
  21. getShapeClass: function(shape, plain) {
  22. var className = '';
  23. if (shape == 'circle') {
  24. className = plain ? 'tui-outline-fillet' : 'tui-fillet';
  25. } else if (shape == "rightAngle") {
  26. className = plain ? 'tui-outline-rightAngle' : 'tui-rightAngle';
  27. }
  28. return className;
  29. },
  30. getHoverClass: function(disabled, type, plain) {
  31. var className = '';
  32. if (!disabled) {
  33. className = plain ? 'tui-outline-hover' : ('tui-' + (type || 'primary') + '-hover');
  34. }
  35. return className;
  36. }
  37. }
  38. </wxs>