Skip to content

Commit 6689ea1

Browse files
committed
update transitions guide with new syntax
1 parent 01c4fc3 commit 6689ea1

File tree

2 files changed

+1182
-322
lines changed

2 files changed

+1182
-322
lines changed

src/guide/components.md

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -909,10 +909,25 @@ new Vue({
909909

910910
``` html
911911
<component v-bind:is="currentView">
912-
<!-- component changes when vm.currentview changes! -->
912+
<!-- component changes when vm.currentView changes! -->
913913
</component>
914914
```
915915

916+
If you prefer, you can also bind directly to component objects:
917+
918+
``` js
919+
var Home = {
920+
template: '<p>Welcome home!</p>'
921+
}
922+
923+
new Vue({
924+
el: 'body',
925+
data: {
926+
currentView: Home
927+
}
928+
})
929+
```
930+
916931
### `keep-alive`
917932

918933
If you want to keep the switched-out components in memory so that you can preserve their state or avoid re-rendering, you can add a `keep-alive` param attribute:
@@ -923,25 +938,15 @@ If you want to keep the switched-out components in memory so that you can preser
923938
</component>
924939
```
925940

926-
### `transition-mode`
927-
928-
The `transition-mode` param attribute allows you to specify how the transition between two dynamic components should be executed.
929-
930-
By default, the transitions for incoming and outgoing components happen simultaneously. This attribute allows you to configure two other modes:
941+
### Transitioning Components
931942

932-
- `in-out`: New component transitions in first, then current component transitions out after incoming transition has finished.
933-
934-
- `out-in`: Current component transitions out first, then new component transitions in after outgoing transition has finished.
935-
936-
Here's a simple example:
943+
Just as we did [with elements](transitions.html#Transitioning-Between-Elements), we can transition between components, but we don't need the `key` attribute:
937944

938945
``` html
939946
<!-- fade out first, then fade in -->
940-
<component
941-
v-bind:is="view"
942-
transition="fade"
943-
transition-mode="out-in">
944-
</component>
947+
<transition name="fade" mode="out-in">
948+
<component v-bind:is="view"></component>
949+
</transition>
945950
```
946951

947952
``` css
@@ -957,11 +962,9 @@ Here's a simple example:
957962
<div id="transition-mode-demo" class="demo">
958963
<input v-model="view" type="radio" value="v-a" id="a" name="view"><label for="a">A</label>
959964
<input v-model="view" type="radio" value="v-b" id="b" name="view"><label for="b">B</label>
960-
<component
961-
v-bind:is="view"
962-
transition="fade"
963-
transition-mode="out-in">
964-
</component>
965+
<transition name="fade" mode="out-in">
966+
<component v-bind:is="view"></component>
967+
</transition>
965968
</div>
966969
<style>
967970
.fade-enter-active, .fade-leave-active {

0 commit comments

Comments
 (0)