btn-bar.vue 1017 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <view class="btn-bar" :style="style">
  3. <text v-if="icon" class="icon iconfont" :class="icon"></text>
  4. <text class="title">{{ title }}</text>
  5. </view>
  6. </template>
  7. <script>
  8. export default {
  9. name: "btn-bar",
  10. props: {
  11. title: {
  12. type: String,
  13. required: true
  14. },
  15. icon: {
  16. type: String,
  17. required: false
  18. },
  19. type: {
  20. type: String,
  21. default: "normal"
  22. },
  23. color: {
  24. type: String,
  25. default: "#000"
  26. }
  27. },
  28. computed: {
  29. style() {
  30. let color = "#000";
  31. switch (this.type) {
  32. case 'danger':
  33. color = "#f14747";
  34. break;
  35. case 'primary':
  36. color = "#35567f";
  37. break;
  38. }
  39. return `color: ${color};`
  40. }
  41. }
  42. }
  43. </script>
  44. <style lang="scss" scoped>
  45. .btn-bar {
  46. width: 100%;
  47. height: 100rpx;
  48. margin-top: 5rpx;
  49. background-color: white;
  50. line-height: 100rpx;
  51. text-align: center;
  52. display: flex;
  53. justify-content: center;
  54. .icon {
  55. font-size: 40rpx;
  56. font-weight: 600;
  57. margin-right: 10rpx;
  58. }
  59. .title {
  60. font-size: 32rpx;
  61. font-weight: 600;
  62. }
  63. }
  64. </style>