u-toolbar.vue 2.0 KB

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