Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个用表单添加用户的组件,在我提交表单后,离开并返回,我发现我上次写的数据还在。
那么,每次我离开时如何重置(重新初始化)组件?
您是否keep-alive启用了该选项?
keep-alive
<router-view keep-alive></router-view>
这可以解释这种行为。如果这不是问题,您可以canReuse: false在组件route:选项中进行设置:
canReuse: false
route:
export default { // ... route: { canReuse: false } }