nav.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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.3);
  65. opacity: 0;
  66. }
  67. .fade-enter-active,
  68. .fade-leave-active {
  69. transition: opacity .3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
  70. }
  71. .fade-enter,
  72. .fade-leave-active {
  73. opacity: 0;
  74. }
  75. </style>
  76. <template>
  77. <div>
  78. <h2>导航</h2>
  79. <div class="block">
  80. <p>导航可以解决用户在访问页面时:在哪里,去哪里,怎样去的问题。一般导航会有「侧栏导航」和「顶部导航」2 种类型。</p>
  81. </div>
  82. <div class="block">
  83. <h3>选择合适的导航</h3>
  84. <p>选择合适的导航可以让用户在产品的使用过程中非常流畅,相反若是不合适就会引起用户操作不适(方向不明确),以下是「侧栏导航」和 「顶部导航」的区别。</p>
  85. </div>
  86. <div class="block">
  87. <h3>侧栏导航</h3>
  88. <el-row :gutter="20">
  89. <el-col :span="9">
  90. <p>可将导航栏固定在左侧,提高导航可见性,方便页面之间切换;顶部可放置常用工具,如搜索条、帮助按钮、通知按钮等。适用于中后台的管理型、工具型网站。</p>
  91. </el-col>
  92. <el-col :span="15" class="nav-demos">
  93. <img src="~examples/assets/images/navbar_1.png" alt="一级类目" @click="enlarge(846, $event)">
  94. <h5>一级类目</h5>
  95. <p>适用于结构简单的网站:只有一级页面时,不需要使用面包屑。</p>
  96. <img src="~examples/assets/images/navbar_2.png" alt="二级类目" @click="enlarge(846, $event)">
  97. <h5>二级类目</h5>
  98. <p>侧栏中最多可显示两级导航;当使用二级导航时,我们建议搭配使用面包屑,方便用户定位自己的位置和快速返回。</p>
  99. <img src="~examples/assets/images/navbar_3.png" alt="三级类目" @click="enlarge(846, $event)">
  100. <h5>三级类目</h5>
  101. <p>适用于较复杂的工具型后台,左侧栏为一级导航,中间栏可显示其对应的二级导航,也可放置其他的工具型选项。</p>
  102. </el-col>
  103. </el-row>
  104. </div>
  105. <div class="block">
  106. <h3>顶部导航</h3>
  107. <el-row>
  108. <el-col :span="10">
  109. <p>顺应了从上至下的正常浏览顺序,方便浏览信息;顶部宽度限制了导航的数量和文本长度。</p>
  110. </el-col>
  111. <el-col :span="14" class="nav-demos">
  112. <img src="~examples/assets/images/navbar_0.png" alt="" @click="enlarge(846, $event)">
  113. <p>适用于导航较少,页面篇幅较长的网站;</p>
  114. </el-col>
  115. </el-row>
  116. </div>
  117. <transition name="fade">
  118. <div class="mask" v-show="showDialog" @click="showDialog = false"></div>
  119. </transition>
  120. <transition name="zoom">
  121. <div class="dialog-img" :style='imgWrapStyle' v-show="showDialog" @click="showDialog = false">
  122. <div class="imgWrap" :style="imgStyle">
  123. <img :src="imgUrl" alt="">
  124. </div>
  125. </div>
  126. </transition>
  127. </div>
  128. </template>
  129. <script>
  130. export default {
  131. data() {
  132. return {
  133. imgUrl: '',
  134. imgBound: {},
  135. showDialog: false,
  136. imgStyle: {},
  137. imgWrapStyle: {}
  138. };
  139. },
  140. watch: {
  141. showDialog(val) {
  142. document.body.style.overflow = val ? 'hidden' : '';
  143. }
  144. },
  145. methods: {
  146. enlarge(imgWidth, ev) {
  147. var imgNode = ev.target;
  148. // var bound = imgNode.getBoundingClientRect();
  149. var offset = {};
  150. var doc = document;
  151. offset.left = (doc.body.scrollWidth - imgWidth) / 2;
  152. offset.top = 100;
  153. this.imgUrl = imgNode.src;
  154. this.imgBound = imgNode.getBoundingClientRect();
  155. this.imgWrapStyle.transformOrigin = `${ev.clientX}px ${ev.clientY}px`;
  156. // this.imgStyle.transformOrigin = `${ev.clientX}px ${ev.clientY}px`;
  157. this.imgStyle.width = imgWidth + 'px';
  158. this.showDialog = true;
  159. }
  160. }
  161. };
  162. </script>