demonav.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <div class="demo-nav" v-if="showFlag">
  3. <div class="goback" @click="goback">
  4. <b class="go-btn"></b>
  5. </div>
  6. <div class="title">{{title}}</div>
  7. <a class="home" :href="'http://git.jd.com/jdcfe/NutUI2/blob/dev/src/demo/'+title.toLowerCase()+'.vue'"></a>
  8. </div>
  9. </template>
  10. <script>
  11. export default {
  12. data(){
  13. return{
  14. showPath:''
  15. }
  16. },
  17. methods:{
  18. goback(){
  19. if (self != top || history.length===1) {
  20. this.$router.push('./index');
  21. }else{
  22. history.back();
  23. }
  24. },
  25. },
  26. computed:{
  27. showFlag(){
  28. if(this.showPath == '/index'){
  29. return false;
  30. }else{
  31. return true;
  32. }
  33. },
  34. title(){
  35. return this.showPath.substring(1);
  36. },
  37. hrefUrl(){
  38. return './index.html#'+this.showPath;
  39. }
  40. },
  41. watch:{
  42. '$route':{
  43. immediate:true,
  44. handler:function(to, from){
  45. this.showPath = to.path;
  46. //document.documentElement.scrollTop = document.body.scrollTop = 0;
  47. }}
  48. },
  49. mounted(){
  50. }
  51. }
  52. </script>
  53. <style>
  54. .demo-nav{
  55. width: 100%;
  56. height: 40px;
  57. background-color: #F8F8F8;
  58. border-bottom: 1px solid #eee;
  59. display:flex;
  60. justify-content: center;
  61. align-items: center;
  62. padding: 0px 8px;
  63. position: fixed;
  64. top:0;
  65. left: 0;
  66. z-index: 1000000;
  67. box-sizing:border-box;
  68. }
  69. .goback{
  70. cursor: pointer;
  71. width: 45px;
  72. height: 40px;
  73. display: flex;
  74. align-items: center;
  75. }
  76. .go-btn{
  77. display: block;
  78. width: 26px;
  79. height: 26px;
  80. background: url("data:image/svg+xml, %3Csvg class='icon' width='200' height='200' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='%23999999' d='M946.5 505L560.1 118.8l-25.9-25.9c-12.3-12.2-32.1-12.2-44.4 0L77.5 505c-12.3 12.3-18.9 28.6-18.8 46 .4 35.2 29.7 63.3 64.9 63.3h42.5V940h691.8V614.3h43.4c17.1 0 33.2-6.7 45.3-18.8 12.1-12.1 18.7-28.2 18.7-45.3 0-17-6.7-33.1-18.8-45.2zM568 868H456V664h112v204zm217.9-325.7V868H632V640c0-22.1-17.9-40-40-40H432c-22.1 0-40 17.9-40 40v228H238.1V542.3h-96l370-369.7 23.1 23.1L882 542.3h-96.1z'/%3E%3C/svg%3E") no-repeat center;
  81. background-size: contain;
  82. }
  83. .title{
  84. flex:1;
  85. font-size: 16px;
  86. text-align: center;
  87. font-weight: bold;
  88. line-height: 40px;
  89. }
  90. .home{
  91. display:inline-block;
  92. width: 24px;
  93. height:100%;
  94. text-decoration:none;
  95. color:#000;
  96. padding:0 10px;
  97. background:url("data:image/svg+xml, %3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='#999' %3E%3Cpath d='M8 .198a8 8 0 0 0-2.529 15.591c.4.074.547-.174.547-.385 0-.191-.008-.821-.011-1.489-2.226.484-2.695-.944-2.695-.944-.364-.925-.888-1.171-.888-1.171-.726-.497.055-.486.055-.486.803.056 1.226.824 1.226.824.714 1.223 1.872.869 2.328.665.072-.517.279-.87.508-1.07-1.777-.202-3.645-.888-3.645-3.954 0-.873.313-1.587.824-2.147-.083-.202-.357-1.015.077-2.117 0 0 .672-.215 2.201.82A7.672 7.672 0 0 1 8 4.066c.68.003 1.365.092 2.004.269 1.527-1.035 2.198-.82 2.198-.82.435 1.102.162 1.916.079 2.117.513.56.823 1.274.823 2.147 0 3.073-1.872 3.749-3.653 3.947.287.248.543.735.543 1.481 0 1.07-.009 1.932-.009 2.195 0 .213.144.462.55.384A8 8 0 0 0 8.001.196z'/%3E%3C/svg%3E") no-repeat center;
  98. background-size:100% auto;
  99. background-origin:content-box;
  100. }
  101. </style>