table.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <div class="table" v-if="selected.length>0">
  3. <ul @click="addTodo">
  4. <nuxt-link to="/">
  5. <li :class="selected[0]">
  6. <span>招投标</span>
  7. </li>
  8. </nuxt-link>
  9. <nuxt-link to="/project">
  10. <li :class="selected[1]">
  11. <span>工程项目</span>
  12. </li>
  13. </nuxt-link>
  14. <nuxt-link to="/map">
  15. <li :class="selected[2]">
  16. <span>项目跟踪</span>
  17. </li>
  18. </nuxt-link>
  19. <nuxt-link to="/me">
  20. <li :class="selected[3]">
  21. <span>我的</span>
  22. </li>
  23. </nuxt-link>
  24. </ul>
  25. </div>
  26. </template>
  27. <script>
  28. import '~/assets/a.scss'
  29. export default {
  30. data() {
  31. return {
  32. selected: ['selected']
  33. }
  34. },
  35. created: function() {
  36. this.addTodo()
  37. },
  38. methods: {
  39. addTodo(e) {
  40. const selected = []
  41. if (this.$route.path == '/') {
  42. selected[0] = 'selected'
  43. } else if (this.$route.path == '/project') {
  44. selected[1] = 'selected'
  45. } else if (this.$route.path == '/map') {
  46. selected[2] = 'selected'
  47. } else if (this.$route.path == '/me') {
  48. selected[3] = 'selected'
  49. }
  50. this.selected = selected
  51. }
  52. },
  53. watch: {
  54. $route: {
  55. handler: function(val, oldVal) {
  56. this.addTodo()
  57. },
  58. // 深度观察监听
  59. deep: true
  60. }
  61. }
  62. }
  63. </script>