Static GitHub Issues

[1520] Why does client side rendering wrong when i add routes from plugins?

prev: disable vuex strict mode on dev
next: Add support for layout transitions

HI there,

I have a problem when I need to add a path through a plugin. I will show my coding as below.

<!-- ~pages/category/_slug.vue -->
<template>
  <div>Category: {{ slug }}</div>
</template>

<script>
export default {
  validate ({ params }) {
    return /^\w+$/.test(params.slug)
  },
  data () {
    return {
      slug: 'default'
    }
  },
  asyncData ({ params }) {
    return {
      slug: params.slug
    }
  }
}
</script>
// nuxt.config.js
// ...
plugins: [
    '~plugins/routes'
]
// ~plugins/routes.js
import Category from '~pages/category/_slug.vue'

export default ({ app }) => {
  app.router.addRoutes([
    { path: '/:slug(cat)', component: Category }
  ])
}

when trying to access "/cat" route, why is the result displayed as Category: cat before it is changed to Category: default at the client side?,

But when i try to access "/category/cat" route is normally. Category: cat

How to resolve this problem?

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1355">#c1355</a>)</em></sub></div>