Crumbs.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <div class="container clearfix" :style="{'minWidth':minWidth?minWidth:'980px',position:fix?fix:'absolute'}">
  3. <img
  4. v-if="linkTo"
  5. class="return-btn fl"
  6. src="../../images/return.png"
  7. alt="返回按钮"
  8. @click="goBack"
  9. />
  10. <h4 class="fl" :title="isShowEllipsis ? title : ''" ref="title">{{title}}</h4>
  11. <div class="contents fr">
  12. <slot></slot>
  13. </div>
  14. </div>
  15. </template>
  16. <script>
  17. export default {
  18. name: 'crumbs',
  19. props: ['title', 'linkTo', 'minWidth', 'param','fix'], //minWidth-有些头部选项比较多,最小宽度需要调整
  20. data: function() {
  21. return {
  22. isShowEllipsis: false // 是否显示文字省略号
  23. };
  24. },
  25. mounted() {
  26. setTimeout(() => {
  27. let titleText = this.$refs.title.innerText;
  28. if (titleText.length > 19) {
  29. this.isShowEllipsis = true;
  30. }
  31. }, 200);
  32. // console.log(this.isShowEllipsis,'isShowEllipsis');
  33. },
  34. methods: {
  35. goBack() {
  36. this.$router.push({
  37. name: this.linkTo,
  38. params: this.param
  39. });
  40. }
  41. }
  42. };
  43. </script>
  44. <style lang="less" scoped>
  45. @import '../../less/common.less';
  46. div.container {
  47. width: calc(100% - 50px);
  48. height: 40px;
  49. background: #fff;
  50. padding: 0 20px 0 30px;
  51. margin-bottom: 20px;
  52. line-height: 40px;
  53. position: absolute;
  54. z-index: 5;
  55. // min-width: 980px;
  56. }
  57. .return-btn {
  58. margin: 11px 5px 0 0;
  59. cursor: pointer;
  60. }
  61. h4 {
  62. font-size: 15px;
  63. width: auto;
  64. overflow: hidden; /*超出部分隐藏*/
  65. white-space: nowrap; /*不换行*/
  66. text-overflow: ellipsis; /*超出部分文字以...显示*/
  67. }
  68. </style>