Skip to content

Commit 7f11327

Browse files
author
User
committed
added Global API
1 parent 5e4514e commit 7f11327

File tree

3 files changed

+61
-19
lines changed

3 files changed

+61
-19
lines changed

API.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ const GlobalAPI = [
1919
G_API.SET,
2020
G_API.DELETE,
2121
G_API.DIRECTIVE,
22-
G_API.FILTER
22+
G_API.FILTER,
23+
G_API.COMPONENT,
24+
G_API.USE,
25+
G_API.MIXIN,
26+
G_API.COMPILE,
27+
G_API.VERSION
2328
]
2429

2530

apis/globalapi.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ const COMPILE = {
176176
],
177177
usage: `Compiles a template string into a render function. ${chalk.bold(`Only available
178178
in the full build`)}.`,
179-
example:`${colorArgs('var')} res = Vue.compile(${chalk.green("'<div><span>{{msg}}</span></div>'")})
179+
example:`
180+
${colorArgs('var')} res = Vue.compile(${chalk.green("'<div><span>{{msg}}</span></div>'")})
180181
${colorArgs('new')} Vue({
181182
data: {
182183
msg: ${chalk.green("'hello'")}
@@ -194,7 +195,8 @@ const VERSION = {
194195
usage: `Provides the installed version of Vue as a string. This is
195196
especially useful for community plugins and components,
196197
where you might use different strategies for different versions.`,
197-
example: `${colorArgs('var')} version = ${chalk.green('Number')}(Vue.version.split(${chalk.green("'.'")})[${colorPrimitive('0')}])
198+
example: `
199+
${colorArgs('var')} version = ${chalk.green('Number')}(Vue.version.split(${chalk.green("'.'")})[${colorPrimitive('0')}])
198200
${colorArgs('if')} (version === ${colorPrimitive('2')}) {
199201
${colorComment('// Vue v2.x.x')}
200202
} ${colorArgs('else if')} (version === ${colorPrimitive('1')}) {
@@ -210,5 +212,10 @@ module.exports = {
210212
SET,
211213
DELETE,
212214
DIRECTIVE,
213-
FILTER
215+
FILTER,
216+
COMPONENT,
217+
USE,
218+
MIXIN,
219+
COMPILE,
220+
VERSION
214221
}

vue-help.js

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,94 +9,124 @@ V.delimiter('vue-help$').show()
99

1010
// Global Config
1111

12-
V.command('silent', 'Outputs "Global Config: #silent"').action(function(args, callback){
12+
V.command('silent', 'Global Config: #silent').action(function(args, callback){
1313
const silent= gc[0]
1414
this.log(LGC.logGlobalConfig(silent))
1515
callback()
1616
})
1717

18-
V.command('optionMergeStrategies', 'Outputs "Global Config: #optionMergeStrategies"').action(function(args, callback){
18+
V.command('optionMergeStrategies', 'Global Config: #optionMergeStrategies').action(function(args, callback){
1919
const optMergeStrat = gc[1]
2020
this.log(LGC.logGlobalConfig(optMergeStrat))
2121
callback()
2222
})
2323

24-
V.command('devtools', 'Outputs "Global Config: #devtools"').action(function(args, callback){
24+
V.command('devtools', 'Global Config: #devtools').action(function(args, callback){
2525
const devtools = gc[2]
2626
this.log(LGC.logGlobalConfig(devtools))
2727
callback()
2828
})
2929

30-
V.command('errorHandler', 'Outputs "Global Config: #errorHandler"').action(function(args, callback){
30+
V.command('errorHandler', 'Global Config: #errorHandler').action(function(args, callback){
3131
const errorHandler = gc[3]
3232
this.log(LGC.logGlobalConfig(errorHandler))
3333
callback()
3434
})
3535

36-
V.command('warnHandler', 'Outputs "Global Config: #warnHandler"').action(function(args, callback){
36+
V.command('warnHandler', 'Global Config: #warnHandler').action(function(args, callback){
3737
const warnHandler = gc[4]
3838
this.log(LGC.logGlobalConfig(warnHandler))
3939
callback()
4040
})
4141

42-
V.command('ignoredElements', 'Outputs "Global Config: #ignoredElements"').action(function(args, callback){
42+
V.command('ignoredElements', 'Global Config: #ignoredElements').action(function(args, callback){
4343
const ignoredElements = gc[5]
4444
this.log(LGC.logGlobalConfig(ignoredElements))
4545
callback()
4646
})
4747

48-
V.command('keyCodes', 'Outputs "Global Config: #keyCodes"').action(function(args, callback){
48+
V.command('keyCodes', 'Global Config: #keyCodes').action(function(args, callback){
4949
const keyCodes = gc[6]
5050
this.log(LGC.logGlobalConfig(keyCodes))
5151
callback()
5252
})
5353

54-
V.command('performance', 'Outputs "Global Config: #performance"').action(function(args, callback){
54+
V.command('performance', 'Global Config: #performance').action(function(args, callback){
5555
const perf = gc[7]
5656
this.log(LGC.logGlobalConfig(perf))
5757
callback()
5858
})
5959

60-
V.command('productionTip', 'Outputs "Global Config: #productionTip"').action(function(args, callback){
60+
V.command('productionTip', 'Global Config: #productionTip').action(function(args, callback){
6161
const prod = gc[8]
6262
this.log(LGC.logGlobalConfig(prod))
6363
callback()
6464
})
6565

6666
// Global API
6767

68-
V.command('extend', 'Outputs "Global API: #Vue.extend(options)"').action(function(args, callback){
68+
V.command('extend', 'Global API: #Vue.extend(options)').action(function(args, callback){
6969
const ext = ga[0]
7070
this.log(LGA.logGlobalAPI(ext))
7171
callback()
7272
})
7373

74-
V.command('nextTick', 'Outputs "Global API: #Vue.nextTick([callback,context])"').action(function(args, callback){
74+
V.command('nextTick', 'Global API: #Vue.nextTick([callback,context])').action(function(args, callback){
7575
const nextTick = ga[1]
7676
this.log(LGA.logGlobalAPI(nextTick))
7777
callback()
7878
})
7979

80-
V.command('set', 'Outputs "Global API: #Vue.set(target,key,value)"').action(function(args, callback){
80+
V.command('set', 'Global API: #Vue.set(target,key,value)').action(function(args, callback){
8181
const st = ga[2]
8282
this.log(LGA.logGlobalAPI(st))
8383
callback()
8484
})
8585

86-
V.command('delete', 'Outputs "Global API: #Vue.delete(target,key)"').action(function(args, callback){
86+
V.command('delete', 'Global API: #Vue.delete(target,key)').action(function(args, callback){
8787
const dlt = ga[3]
8888
this.log(LGA.logGlobalAPI(dlt))
8989
callback()
9090
})
9191

92-
V.command('directive', 'Outputs "Global API: #Vue.directive(id,[definition])"').action(function(args, callback){
92+
V.command('directive', 'Global API: #Vue.directive(id,[definition])').action(function(args, callback){
9393
const dir = ga[4]
9494
this.log(LGA.logGlobalAPI(dir))
9595
callback()
9696
})
9797

98-
V.command('filter', 'Outputs "Global API: #Vue.filter(id,[definition])"').action(function(args, callback){
98+
V.command('filter', 'Global API: #Vue.filter(id,[definition])').action(function(args, callback){
9999
const flt = ga[5]
100100
this.log(LGA.logGlobalAPI(flt))
101101
callback()
102+
})
103+
104+
V.command('component', 'Global API: #Vue.component(id,[definition])').action(function(args, callback){
105+
const c= ga[6]
106+
this.log(LGA.logGlobalAPI(c))
107+
callback()
108+
})
109+
110+
V.command('use', 'Global API: #Vue.use(plugin)').action(function(args, callback){
111+
const u = ga[7]
112+
this.log(LGA.logGlobalAPI(u))
113+
callback()
114+
})
115+
116+
V.command('mixin', 'Global API: #Vue.mixin(mixin)').action(function(args, callback){
117+
const m = ga[8]
118+
this.log(LGA.logGlobalAPI(m))
119+
callback()
120+
})
121+
122+
V.command('compile', 'Global API: #Vue.compile(template)').action(function(args, callback){
123+
const c = ga[9]
124+
this.log(LGA.logGlobalAPI(c))
125+
callback()
126+
})
127+
128+
V.command('version', 'Global API: #Vue.version').action(function(args, callback){
129+
const v = ga[10]
130+
this.log(LGA.logGlobalAPI(v))
131+
callback()
102132
})

0 commit comments

Comments
 (0)