uv-toolbar.vue 2.5 KB

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