File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -6,10 +6,10 @@ import * as _ from 'lodash'
66
77const hyphenateRE = / ( [ ^ - ] ) ( [ A - Z ] ) / g
88const hyphenate = ( ( str : string ) : string => {
9- return str
10- . replace ( hyphenateRE , '$1-$2' )
11- . replace ( hyphenateRE , '$1-$2' )
12- . toLowerCase ( )
9+ return str
10+ . replace ( hyphenateRE , '$1-$2' )
11+ . replace ( hyphenateRE , '$1-$2' )
12+ . toLowerCase ( )
1313} )
1414
1515export function register_all_components ( vue : typeof Vue , prefix : string ) {
@@ -40,7 +40,16 @@ export function register_all_methods(vue: typeof Vue, instance) {
4040 mdls [ k ] = modules [ k ] ( instance , this )
4141 }
4242 for ( var k in components ) {
43- mdls [ _ . camelCase ( k ) ] = ( ref ) => { return this . $refs [ ref ] }
43+ mdls [ _ . camelCase ( k ) ] = ( ref ) => {
44+ if ( typeof ref !== 'string' )
45+ throw new Error ( 'ref must be string represents the ref name of component' )
46+
47+ let component = this . $refs [ ref ]
48+ if ( ! component )
49+ throw new Error ( `Could not resolve ui component in '${ this . $options . name } ' referenced by '${ ref } '.` )
50+
51+ return component
52+ }
4453 }
4554
4655 mdls = _ . merge ( mdls , instance )
You can’t perform that action at this time.
0 commit comments