uni-NavBar.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <view class="navbar dis a-c j-s" :style="{background:background}">
  3. <image class="icon-right" :src="backActionimg" mode="" @tap="back()"></image>
  4. <template v-if="!isSlot">
  5. <text class="title font-weight" :style="titleStyle">{{headerTitle}}</text>
  6. <image class="icon-right" :style="{opacity:isShared?1:0}" :src="rightIcon?rightIcon:shareimg" mode=""
  7. @tap="share">
  8. </image>
  9. </template>
  10. <template v-else>
  11. <slot name="search">
  12. </slot>
  13. </template>
  14. </view>
  15. </template>
  16. <script>
  17. import {
  18. turnBase64Image
  19. } from '@/plugins/utils.js';
  20. export default {
  21. name: 'name', //插件名称
  22. props: {
  23. isSlot: {
  24. type: Boolean,
  25. default: false,
  26. },
  27. headerTitle: {
  28. type: String,
  29. default: 'xxxx'
  30. },
  31. background: {
  32. type: String,
  33. default: '#fff'
  34. },
  35. titleStyle: {
  36. type: Object,
  37. default: () => {
  38. return {};
  39. }
  40. },
  41. rightIcon: {
  42. type: String,
  43. default: null
  44. },
  45. isShared: {
  46. type: Boolean,
  47. default: true,
  48. }
  49. },
  50. computed: {},
  51. data() {
  52. return {
  53. backActionimg: '',
  54. shareimg: '',
  55. };
  56. },
  57. async mounted() {
  58. this.backActionimg = await turnBase64Image('/static/icon/backAction.png')
  59. this.shareimg = await turnBase64Image('/static/icon/share.png')
  60. },
  61. methods: {
  62. share() {
  63. this.$emit('share')
  64. },
  65. back() {
  66. uni.navigateBack(-1)
  67. }
  68. }
  69. };
  70. </script>
  71. <!--使用scss,只在本组件生效-->
  72. <style lang="scss" scoped>
  73. .navbar {
  74. padding: 116rpx 30rpx 16rpx;
  75. box-sizing: border-box;
  76. position: relative;
  77. z-index: 9999;
  78. .title {
  79. font-size: 36rpx;
  80. color: #333;
  81. }
  82. .icon-right {
  83. width: 48rpx;
  84. height: 48rpx;
  85. }
  86. }
  87. </style>