Skip to content

Commit 232a9c4

Browse files
committed
use router-view element directive
1 parent e8b74ee commit 232a9c4

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

example/example.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var root = new Vue({
1212
el: '#app',
1313
components: {
1414
inbox: {
15-
template: '<div><h2>inbox!</h2><div v-view></div></div>',
15+
template: '<div><h2>inbox!</h2><router-view></router-view>',
1616
replace: true,
1717
components: {
1818
message: {
@@ -26,7 +26,7 @@ var root = new Vue({
2626
}
2727
},
2828
user: {
29-
template: '<h2>User yo</h2><div v-view></div>',
29+
template: '<h2>User yo</h2><router-view></router-view>',
3030
components: {
3131
'user-profile': {
3232
template: 'user profile {{route.params.userId}} {{route.params.something}}'

example/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ <h1>App Header</h1>
1212
<a v-link="/inbox/message/123">inbox</a>
1313
<a v-link="/about">about</a>
1414
<a v-link="/user/1234">user</a>
15-
<div v-view class="test" v-transition="test" transition-mode="out-in"></div>
15+
<router-view class="test" v-transition="test" transition-mode="out-in"></router-view>
1616
</div>
1717

1818
<script src="/example.build.js"></script>

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"webpack": "^1.8.11"
3535
},
3636
"dependencies": {
37-
"route-recognizer": "^0.1.5"
37+
"route-recognizer": "^0.1.5",
38+
"insert-css": "^0.2.0"
3839
}
3940
}

src/view.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22

33
module.exports = function (Vue) {
44

5+
// insert global css to make sure router-view has
6+
// display:block so that transitions work properly
7+
require('insert-css')('router-view{display:block;}')
8+
59
var _ = Vue.util
6-
var component = Vue.directive('component')
10+
var component = Vue.directive('_component')
711
var templateParser = Vue.parsers.template
812

913
// v-view extends v-component
@@ -96,6 +100,5 @@ module.exports = function (Vue) {
96100

97101
})
98102

99-
Vue.directive('view', viewDef)
100-
Vue.config._terminalDirectives.push('view')
103+
Vue.elementDirective('router-view', viewDef)
101104
}

0 commit comments

Comments
 (0)