nav.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <style scoped>
  2. h3 {
  3. margin-bottom: 15px;
  4. }
  5. .block {
  6. margin-bottom: 55px;
  7. }
  8. p {
  9. margin: 0 0 15px;
  10. }
  11. .nav-demos {
  12. p {
  13. margin-bottom: 50px;
  14. }
  15. h5 {
  16. margin: 0;
  17. }
  18. img {
  19. padding: 15px;
  20. background-color: #F9FAFC;
  21. width: 100%;
  22. margin-bottom: 15px;
  23. cursor: pointer;
  24. }
  25. }
  26. .dialog-img {
  27. position: fixed;
  28. overflow: auto;
  29. top: 0;
  30. right: 0;
  31. bottom: 0;
  32. left: 0;
  33. z-index: 1000;
  34. -webkit-overflow-scrolling: touch;
  35. outline: 0;
  36. .imgWrap {
  37. margin: 0 auto;
  38. position: relative;
  39. top: 100px;
  40. padding-bottom: 50px;
  41. }
  42. img {
  43. display: block;
  44. width: 100%;
  45. }
  46. }
  47. .mask {
  48. position: fixed;
  49. top: 0;
  50. right: 0;
  51. left: 0;
  52. bottom: 0;
  53. background-color: #373737;
  54. background-color: rgba(55, 55, 55, 0.6);
  55. height: 100%;
  56. z-index: 1000;
  57. }
  58. .zoom-enter-active,
  59. .zoom-leave-active {
  60. transition: transform .3s cubic-bezier(0.78, 0.14, 0.15, 0.86), opacity .3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
  61. }
  62. .zoom-enter,
  63. .zoom-leave-active {
  64. transform: scale(0);
  65. opacity: 0;
  66. }
  67. </style>
  68. <template>
  69. <div>
  70. <h2>导航</h2>
  71. <div class="block">
  72. <p>导航可以解决用户在访问页面时:在哪里,去哪里,怎样去的问题。一般导航会有「侧栏导航」和「顶部导航」2 种类型。</p>
  73. </div>
  74. <div class="block">
  75. <h3>选择合适的导航</h3>
  76. <p>选择合适的导航可以让用户在产品的使用过程中非常流畅,相反若是不合适就会引起用户操作不适(方向不明确),以下是「侧栏导航」和 「顶部导航」的区别。</p>
  77. </div>
  78. <div class="block">
  79. <h3>侧栏导航</h3>
  80. <el-row :gutter="20">
  81. <el-col :span="9">
  82. <p>可将导航栏固定在左侧,提高导航可见性,方便页面之间切换;顶部可放置常用工具,如搜索条、帮助按钮、通知按钮等。适用于中后台的管理型、工具型网站。</p>
  83. </el-col>
  84. <el-col :span="15" class="nav-demos">
  85. <img src="~examples/assets/images/navbar_1.png" alt="一级类目" @click="enlarge(846, $event)">
  86. <h5>一级类目</h5>
  87. <p>适用于结构简单的网站:只有一级页面时,不需要使用面包屑。</p>
  88. <img src="~examples/assets/images/navbar_2.png" alt="二级类目" @click="enlarge(846, $event)">
  89. <h5>二级类目</h5>
  90. <p>侧栏中最多可显示两级导航;当使用二级导航时,我们建议搭配使用面包屑,方便用户定位自己的位置和快速返回。</p>
  91. <img src="~examples/assets/images/navbar_3.png" alt="三级类目" @click="enlarge(846, $event)">
  92. <h5>三级类目</h5>
  93. <p>适用于较复杂的工具型后台,左侧栏为一级导航,中间栏可显示其对应的二级导航,也可放置其他的工具型选项。</p>
  94. </el-col>
  95. </el-row>
  96. </div>
  97. <div class="block">
  98. <h3>顶部导航</h3>
  99. <el-row>
  100. <el-col :span="10">
  101. <p>顺应了从上至下的正常浏览顺序,方便浏览信息;顶部宽度限制了导航的数量和文本长度。</p>
  102. </el-col>
  103. <el-col :span="14" class="nav-demos">
  104. <img src="~examples/assets/images/navbar_0.png" alt="" @click="enlarge(846, $event)">
  105. <p>适用于导航较少,页面篇幅较长的网站;</p>
  106. </el-col>
  107. </el-row>
  108. </div>
  109. <div class="mask" v-show="showDialog" @click="showDialog = false"></div>
  110. <div class="dialog-img" v-show="showDialog" @click="showDialog = false">
  111. <transition name="zoom">
  112. <div class="imgWrap" :style="imgStyle" v-show="showDialog">
  113. <img src="~examples/assets/images/navbar_2.png" alt="">
  114. </div>
  115. </transition>
  116. </div>
  117. </div>
  118. </template>
  119. <script>
  120. export default {
  121. data() {
  122. return {
  123. imgUrl: '',
  124. imgBound: {},
  125. showDialog: false,
  126. imgStyle: {}
  127. };
  128. },
  129. watch: {
  130. showDialog(val) {
  131. document.body.style.overflow = val ? 'hidden' : '';
  132. }
  133. },
  134. methods: {
  135. enlarge(imgWidth, ev) {
  136. var imgNode = ev.target;
  137. // var bound = imgNode.getBoundingClientRect();
  138. var offset = {};
  139. var doc = document;
  140. offset.left = (doc.body.scrollWidth - imgWidth) / 2;
  141. offset.top = 100;
  142. this.imgUrl = imgNode.src;
  143. this.imgBound = imgNode.getBoundingClientRect();
  144. this.imgStyle.transformOrigin = `${ev.clientX - offset.left}px ${ev.clientY - offset.top}px`;
  145. this.imgStyle.width = imgWidth + 'px';
  146. this.showDialog = true;
  147. }
  148. }
  149. };
  150. </script>