u-toolbar.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <view
  3. class="u-toolbar"
  4. @touchmove.stop.prevent="noop"
  5. v-if="show"
  6. >
  7. <view
  8. class="u-toolbar__cancel__wrapper"
  9. hover-class="u-hover-class"
  10. >
  11. <text
  12. class="u-toolbar__wrapper__cancel"
  13. @tap="cancel"
  14. :style="{
  15. color: cancelColor
  16. }"
  17. >{{ cancelText }}</text>
  18. </view>
  19. <text
  20. class="u-toolbar__title u-line-1"
  21. v-if="title"
  22. >{{ title }}</text>
  23. <view
  24. class="u-toolbar__confirm__wrapper"
  25. hover-class="u-hover-class"
  26. >
  27. <text
  28. class="u-toolbar__wrapper__confirm"
  29. @tap="confirm"
  30. :style="{
  31. color: confirmColor
  32. }"
  33. >{{ confirmText }}</text>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import props from './props.js';
  39. import mixin from '../../libs/mixin/mixin'
  40. import mpMixin from '../../libs/mixin/mpMixin';
  41. /**
  42. * Toolbar 工具条
  43. * @description
  44. * @tutorial https://uview.d3u.cn/components/toolbar.html
  45. * @property {Boolean} show 是否展示工具条(默认 true )
  46. * @property {String} cancelText 取消按钮的文字(默认 '取消' )
  47. * @property {String} confirmText 确认按钮的文字(默认 '确认' )
  48. * @property {String} cancelColor 取消按钮的颜色(默认 '#909193' )
  49. * @property {String} confirmColor 确认按钮的颜色(默认 '#3c9cff' )
  50. * @property {String} title 标题文字
  51. * @event {Function}
  52. * @example
  53. */
  54. export default {
  55. name: 'u-toolbar',
  56. mixins: [mpMixin, mixin, props],
  57. // #ifdef VUE3
  58. emits: ["cancel", "confirm"],
  59. // #endif
  60. methods: {
  61. // 点击取消按钮
  62. cancel() {
  63. this.$emit('cancel')
  64. },
  65. // 点击确定按钮
  66. confirm() {
  67. this.$emit('confirm')
  68. }
  69. },
  70. }
  71. </script>
  72. <style lang="scss" scoped>
  73. @import "../../libs/css/components.scss";
  74. .u-toolbar {
  75. height: 42px;
  76. @include flex;
  77. justify-content: space-between;
  78. align-items: center;
  79. &__wrapper {
  80. &__cancel {
  81. color: $u-tips-color;
  82. font-size: 15px;
  83. padding: 0 15px;
  84. }
  85. }
  86. &__title {
  87. color: $u-main-color;
  88. padding: 0 60rpx;
  89. font-size: 16px;
  90. flex: 1;
  91. text-align: center;
  92. }
  93. &__wrapper {
  94. &__confirm {
  95. color: $u-primary;
  96. font-size: 15px;
  97. padding: 0 15px;
  98. }
  99. }
  100. }
  101. </style>