button.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <view>
  3. <page-head :title="title"></page-head>
  4. <view class="uni-padding-wrap uni-common-mt">
  5. <button type="primary">页面主操作 Normal</button>
  6. <button type="primary" :loading="loading">页面主操作 Loading</button>
  7. <button type="primary" disabled="true">页面主操作 Disabled</button>
  8. <button type="default">页面次要操作 Normal</button>
  9. <button type="default" disabled="true">页面次要操作 Disabled</button>
  10. <button type="warn">警告类操作 Normal</button>
  11. <button type="warn" disabled="true">警告类操作 Disabled</button>
  12. <view class="button-sp-area">
  13. <button type="primary" plain="true">按钮</button>
  14. <button type="primary" disabled="true" plain="true">不可点击的按钮</button>
  15. <button type="default" plain="true">按钮</button>
  16. <button type="default" disabled="true" plain="true">按钮</button>
  17. <button class="mini-btn" type="primary" size="mini">按钮</button>
  18. <button class="mini-btn" type="default" size="mini">按钮</button>
  19. <button class="mini-btn" type="warn" size="mini">按钮</button>
  20. </view>
  21. <!-- #ifdef MP-WEIXIN || MP-QQ -->
  22. <button open-type="launchApp" app-parameter="uni-app" @error="openTypeError">打开APP</button>
  23. <button open-type="feedback">意见反馈</button>
  24. <!-- #endif -->
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. data() {
  31. return {
  32. title: 'button',
  33. loading: false
  34. }
  35. },
  36. onLoad() {
  37. this._timer = null;
  38. },
  39. onShow() {
  40. this.clearTimer();
  41. this._timer = setTimeout(() => {
  42. this.loading = true;
  43. }, 300)
  44. },
  45. onUnload() {
  46. this.clearTimer();
  47. this.loading = false;
  48. },
  49. methods: {
  50. openTypeError(error) {
  51. console.error('open-type error:', error);
  52. },
  53. clearTimer() {
  54. if (this._timer != null) {
  55. clearTimeout(this._timer);
  56. }
  57. }
  58. }
  59. }
  60. </script>
  61. <style>
  62. button {
  63. margin-top: 30rpx;
  64. margin-bottom: 30rpx;
  65. }
  66. .button-sp-area {
  67. margin: 0 auto;
  68. width: 60%;
  69. }
  70. .mini-btn {
  71. margin-right: 10rpx;
  72. }
  73. </style>