You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
2.1 KiB

2 months ago
  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';
  39. import { mpMixin } from '../../libs/mixin/mpMixin';
  40. import { mixin } from '../../libs/mixin/mixin';
  41. /**
  42. * Toolbar 工具条
  43. * @description
  44. * @tutorial https://ijry.github.io/uview-plus/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. emits: ["confirm", "cancel"],
  58. methods: {
  59. // 点击取消按钮
  60. cancel() {
  61. this.$emit('cancel')
  62. },
  63. // 点击确定按钮
  64. confirm() {
  65. this.$emit('confirm')
  66. }
  67. },
  68. }
  69. </script>
  70. <style lang="scss" scoped>
  71. @import "../../libs/css/components.scss";
  72. .u-toolbar {
  73. height: 42px;
  74. @include flex;
  75. justify-content: space-between;
  76. align-items: center;
  77. &__wrapper {
  78. &__cancel {
  79. color: $u-tips-color;
  80. font-size: 15px;
  81. padding: 0 15px;
  82. }
  83. }
  84. &__title {
  85. color: $u-main-color;
  86. padding: 0 60rpx;
  87. font-size: 16px;
  88. flex: 1;
  89. text-align: center;
  90. }
  91. &__wrapper {
  92. &__confirm {
  93. color: $u-primary;
  94. font-size: 15px;
  95. padding: 0 15px;
  96. }
  97. }
  98. }
  99. </style>