hash模式下Vue + NUXT有点问题,普通history
模式下没有问题。
当我们有 url: /#/test/1
并将其更改为 /#/test/2
时,$router
内容会更新到适当的路径,但没有触发任何反应。在更改哈希 URL 时触发反应性的正确方法是什么?
我检查了 keep-alive
和默认组件的 key
属性,弄乱这些似乎没有帮助,但我可能做错了。
我认为是相关的组件代码:
// template using current_organization
<script>
import {mapState} from 'vuex'
export default {
computed: mapState({
current_organization: state => state.user.organization,
}),
}
</script>
我可以在浏览器中使用观察者或 addEventListener
哈希更改并打印出 $route
..一切似乎都设置正确!组织已设置,但组件未正确重绘。
答案 0 :(得分:0)
我想出了我的问题所在。我指的是商店:state.user.organization
以及某些区域的 $route.params.organization
。通过在我的代码中只使用 $route.params.organization
,一切都“正常工作!”