u-toolbar.vue 2.1 KB

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