fix(vue-app): remove trailing slash in vue-router non-strict mode (#5746)

This commit is contained in:
Xin Du (Clark) 2019-05-17 10:39:52 +01:00 committed by GitHub
parent b0f955230a
commit 30419e73f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,7 +41,8 @@ export default {
return this.nuxtChildKey || compile(this.$route.matched[0].path)(this.$route.params) return this.nuxtChildKey || compile(this.$route.matched[0].path)(this.$route.params)
} }
const Component = this.$route.matched[0] && this.$route.matched[0].components.default const [matchedRoute] = this.$route.matched
const Component = matchedRoute && matchedRoute.components.default
if (Component && Component.options) { if (Component && Component.options) {
const { key, watchQuery } = Component.options const { key, watchQuery } = Component.options
@ -64,7 +65,8 @@ export default {
} }
} }
return this.$route.path const strict = /\/$/.test(matchedRoute.path)
return strict ? this.$route.path : this.$route.path.replace(/\/$/, '')
} }
}, },
beforeCreate() { beforeCreate() {