我将哈希设置为变量to
的属性
router.beforeEach((to, from, next) => {
to.hash = '';
});
它给出了这个错误:
keycloak.js?ff98:24 Uncaught TypeError: Cannot assign to read only property 'hash' of object '#<Object>'
at Object.eval [as successCallback] (keycloak.js?ff98:24)
at Object.setSuccess (keycloak.js?68ad:1030)
at Object.eval [as successCallback] (keycloak.js?68ad:133)
at Object.setSuccess (keycloak.js?68ad:1030)
at authSuccess (keycloak.js?68ad:630)
at XMLHttpRequest.req.onreadystatechange (keycloak.js?68ad:603)
...
答案 0 :(得分:0)
您实际上只想将模式设置为"history"
。
const router = new VueRouter({
mode: "history"
})
尽管如此,请确保将服务器配置为处理这些链接。 https://router.vuejs.org/guide/essentials/history-mode.html