@@ -91,15 +91,25 @@ const Quux = {
91
91
}
92
92
93
93
const NestedParent = {
94
- template : `<div id="nested-parent">Nested Parent <hr>
95
- <router-link to="/parent/child/1">/parent/child/1</router-link>
96
- <router-link to="/parent/child/2">/parent/child/2</router-link>
97
- <hr>
98
- <p id="bre-order">
99
- <span v-for="log in logs">{{ log }} </span>
100
- </p>
101
-
102
- <router-view/></div>` ,
94
+ template : `
95
+ <div id="nested-parent">
96
+ Nested Parent
97
+ <hr>
98
+ <router-link to="/parent/child/1">/parent/child/1</router-link>
99
+ <router-link to="/parent/child/2">/parent/child/2</router-link>
100
+ <hr>
101
+ <p id="bre-order">
102
+ <span v-for="log in logs">{{ log }} </span>
103
+ </p>
104
+ <!-- #705 -->
105
+ <!-- Some transitions, specifically out-in transitions, cause the view -->
106
+ <!-- that is transitioning in to appear significantly later than normal, -->
107
+ <!-- which can cause bugs as "vm" below in "next(vm => ...)" may not be -->
108
+ <!-- available at the time the callback is called -->
109
+ <transition name="fade" mode="out-in">
110
+ <router-view/>
111
+ </transition>
112
+ </div>` ,
103
113
data : ( ) => ( { logs : [ ] } ) ,
104
114
beforeRouteEnter ( to , from , next ) {
105
115
next ( vm => {
@@ -116,7 +126,18 @@ const GuardMixin = {
116
126
}
117
127
}
118
128
119
- const NestedChild = {
129
+ const NestedChild1 = {
130
+ props : [ 'n' ] ,
131
+ template : `<div>Child {{ n }}</div>` ,
132
+ mixins : [ GuardMixin ] ,
133
+ beforeRouteEnter ( to , from , next ) {
134
+ next ( vm => {
135
+ vm . $parent . logs . push ( 'child ' + vm . n )
136
+ } )
137
+ }
138
+ }
139
+
140
+ const NestedChild2 = {
120
141
props : [ 'n' ] ,
121
142
template : `<div>Child {{ n }}</div>` ,
122
143
mixins : [ GuardMixin ] ,
@@ -162,10 +183,10 @@ const router = new VueRouter({
162
183
path : '/parent' ,
163
184
component : NestedParent ,
164
185
children : [
165
- { path : 'child/1' , component : NestedChild , props : { n : 1 } } ,
166
- { path : 'child/2' , component : NestedChild , props : { n : 2 } }
186
+ { path : 'child/1' , component : NestedChild1 , props : { n : 1 } } ,
187
+ { path : 'child/2' , component : NestedChild2 , props : { n : 2 } }
167
188
]
168
- }
189
+ } ,
169
190
]
170
191
} )
171
192
0 commit comments