index.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <div id="station">
  3. <ul>
  4. <li v-for="(tab,index) in tabs" @click="toggle(index,tab.view)" :class="{active:active==index}">
  5. {{tab.type}}
  6. </li>
  7. </ul>
  8. <!--:is实现多个组件实现同一个挂载点-->
  9. <component :is="currentView"></component>
  10. </div>
  11. </template>
  12. <script>
  13. import info from '../info/index.vue'
  14. import pay from '../pay/index.vue'
  15. import notice from '../notice/index.vue'
  16. export default {
  17. name: 'Common',
  18. data(){
  19. return {
  20. active:0,
  21. currentView:'油站信息',
  22. tabs:[
  23. {
  24. type:'油站信息',
  25. view:'info'
  26. },
  27. {
  28. type:'支付配置',
  29. view:'pay'
  30. },
  31. {
  32. type:'设备管理',
  33. view:'notice'
  34. }
  35. ]
  36. }
  37. },
  38. methods:{
  39. toggle(i,v){
  40. this.active=i;
  41. this.currentView=v;
  42. }
  43. },
  44. components:{
  45. info,
  46. pay,
  47. notice
  48. }
  49. }
  50. </script>
  51. <style>
  52. #station {
  53. font-family: 'Avenir', Helvetica, Arial, sans-serif;
  54. -webkit-font-smoothing: antialiased;
  55. -moz-osx-font-smoothing: grayscale;
  56. /* text-align: center;
  57. color: #2c3e50;
  58. margin-top: 60px; */
  59. }
  60. ul{
  61. width:500px;
  62. display:flex;
  63. }
  64. ul li{
  65. width:100px;
  66. height:40px;
  67. /*background: #ccc;*/
  68. display: inline-flex;
  69. border-right:1px solid #ddd;
  70. justify-content: center;
  71. align-items: center;
  72. cursor:pointer
  73. }
  74. ul li.active{
  75. /*background:#333;*/
  76. }
  77. </style>