【问题标题】:Previous route showing in current route in Sapper以前的路线显示在 Sapper 的当前路线中
【发布时间】:2020-03-16 03:54:18
【问题描述】:

我有两条路线/questions 和/profile。在onDestroy() 生命周期事件中,我调用了console.log('destroyed')。当我在路由之间切换时,我每次都会在 Chrome 控制台中“销毁”。

问题是在/questions 路由中,我有复选框,使用bind:group={multiple_ids} 绑定。因此,在选中/取消选中某个字段后,当我从 /question 切换到 /profile 路由时。 /question 路由的内容显示在 /profile 路由内,此后 Chrome 控制台不再显示“已销毁”!这种行为对我来说似乎很奇怪。我不知道发生了什么。这是一个工作项目。请解决这个问题。谢谢

【问题讨论】:

    标签: routes sapper svelte-3


    【解决方案1】:

    您的组件中有过渡吗?根据这个bug-report,元素可以在导航后出现在其他路线中。听起来很像您遇到的问题。

    一种解决方案是使用|local 修饰符作为过渡属性。查看API docs 了解如何应用它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-01-28
      • 1970-01-01
      • 2016-10-31
      • 1970-01-01
      • 2019-07-15
      • 2018-10-12
      • 1970-01-01
      相关资源
      最近更新 更多