使用Vue 2.6.14,Vue路由器设置为历史模式,URL包含一个标签"#"打破了动态路径。
const router = new VueRouter({
base: `${process.env.VUE_APP_PUBLIC_PATH}`,
mode: 'history',
routes: [
{
path: '/document/:documentId(.*)',
name: 'Document',
component: Document,
props: true
},
{
path: '*',
name: 'NotFound',
component: NotFound
}
]
});
以"结尾的URL/文档/#1";作为"的空字符串返回;documentId";道具
documentIdHashtagProof() { return this.documentId ? this.documentId : this.$route.hash; }
问题在于;documentId";返回了空字符串,我已经通过使用读取哈希的计算属性解决了这个问题。