u-toolbar.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 mpMixin from '../../libs/mixin/mpMixin.js';
  40. import mixin from '../../libs/mixin/mixin.js';
  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>