(Vue.js) Same component with different routes

后端 未结 3 1184
别跟我提以往
别跟我提以往 2020-12-16 12:53

I would like to use the same component for different routes in a Vue.js application.

I currently have something like this:


main.js

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-16 13:18

    This is expected behaviour as Vue is trying to be optimal and reuse existing components. The behaviour you want to achieve used to be solved with a setting called canReuse, but that has been deprecated. The current recommended solution is to set a unique :key property on your like so:

    
    

    Check out this JSFiddle example.

提交回复
热议问题