pcNav.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <template>
  2. <div class="header-menu">
  3. <nuxt-link to="/" :class="{active : curActive === 'shouye'}">首页</nuxt-link>
  4. <nuxt-link to="/cpyfw" class="xwzx-row" :class="{'active': curActive === 'cpyfw'}">产品与服务</nuxt-link>
  5. <nuxt-link to="/news" class="xwzx-row" :class="{'active': curActive === 'news'}">新闻中心</nuxt-link>
  6. <nuxt-link to="/gywm" :class="{active: curActive === 'gywm'}">关于我们</nuxt-link>
  7. </div>
  8. </template>
  9. <script>
  10. export default {
  11. name: "pcNav",
  12. data() {
  13. return {
  14. }
  15. },
  16. methods:{
  17. headNavClick(){
  18. this.$emit('headNavClick')
  19. },
  20. kckfBtn(){
  21. this.$router.push({ path: '/courseware/synopsis' });
  22. },
  23. },
  24. computed: {
  25. curActive() {
  26. const routerPath = this.$route.path
  27. // 首页
  28. if (routerPath === '/' || routerPath === '/index') {
  29. return 'shouye'
  30. } else if (routerPath === '/cpyfw') {
  31. return 'cpyfw'
  32. }else if (routerPath === '/news') {
  33. return 'news'
  34. } else if (routerPath === '/gywm') {
  35. return 'gywm'
  36. }
  37. }
  38. },
  39. watch: {
  40. '$route.path': {
  41. handler(newVal) {
  42. console.log(newVal)
  43. this.$emit('navChange',newVal)
  44. },
  45. immediate: true,
  46. }
  47. }
  48. }
  49. </script>
  50. <style lang="scss">
  51. </style>