Skip to content

Commit 776e8be

Browse files
committed
move resolveProps into view
1 parent d8fd3fc commit 776e8be

File tree

2 files changed

+21
-28
lines changed

2 files changed

+21
-28
lines changed

src/components/view.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { resolveProps } from '../util/props'
1+
import { warn } from '../util/warn'
22

33
export default {
44
name: 'router-view',
@@ -58,8 +58,27 @@ export default {
5858
matched.instances[name] = undefined
5959
}
6060
}
61-
data.props = resolveProps(route, component, matched.props && matched.props[name])
61+
62+
// resolve props
63+
data.props = resolveProps(route, matched.props && matched.props[name])
6264

6365
return h(component, data, children)
6466
}
6567
}
68+
69+
function resolveProps (route, config) {
70+
switch (typeof config) {
71+
case 'undefined':
72+
return
73+
case 'object':
74+
return config
75+
case 'function':
76+
return config(route)
77+
case 'boolean':
78+
if (config) {
79+
return route.params
80+
}
81+
default:
82+
warn(false, `props in "${route.path}" is a ${typeof config}, expecting an object, function or boolean.`)
83+
}
84+
}

src/util/props.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)