Skip to content

Commit fbc2ee3

Browse files
author
User
committed
added to Global API
1 parent 710aad6 commit fbc2ee3

File tree

4 files changed

+73
-11
lines changed

4 files changed

+73
-11
lines changed

API.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ const GlobalConfig = [
1414
]
1515

1616
const GlobalAPI = [
17-
G_API.EXTEND
17+
G_API.EXTEND,
18+
G_API.NEXT_TICK,
19+
G_API.SET,
20+
G_API.DELETE
1821
]
1922

2023

apis/globalapi.js

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,52 @@ const EXTEND = {
3535
}
3636

3737
const NEXT_TICK = {
38-
38+
category: 'Global API',
39+
name: 'Vue.nextTick([callback, context])',
40+
arguments: [
41+
`{Function} [callback]`,
42+
`{Object} [context]`
43+
],
44+
usage: `Defer the callback to be executed after the next DOM update cycle.
45+
Use it immediately after you've changed some data to wait
46+
for the DOM update.`,
47+
example: `${colorComment('// modify data')}
48+
vm.msg = ${chalk.green("'Hello'")}
49+
Vue.nextTick(${chalk.blue('function')} () {
50+
${colorComment('// DOM update')}
51+
})`
3952
}
4053

4154
const SET = {
42-
55+
category: 'Global API',
56+
name: 'Vue.set(target,key,value)',
57+
arguments:[
58+
`{Object | Array} target`,
59+
`{string | number} key`,
60+
`{any} value`
61+
],
62+
returns: 'the set value',
63+
usage: `Set a property on an object. If the object is reactive, ensure
64+
the property is created as a reactive property and
65+
trigger view updates. This is primarily used to get around
66+
the limitation that Vue cannot detect property additions.
67+
${chalk.redBright.bold(`Note the object cannot be a Vue instance, or the root data
68+
object of a Vue instance.`)}`
4369
}
4470

4571
const DELETE = {
72+
category: 'Global API',
73+
name: 'Vue.delete(target,key)',
74+
arguments: [
75+
`{Object | Array} target`,
76+
`{string | number} key`
77+
],
78+
usage: `Delete a property on an object. If the object is reactive, ensure the
79+
deletion triggers view updates. This is primarily used to get
80+
around the limitation that Vue cannot detect property deletions,
81+
but you should rarely need to use it.
82+
${chalk.redBright.bold(`The target object cannot be a Vue instance, or the root data
83+
object of a Vue instance.`)}`
4684

4785
}
4886

@@ -75,5 +113,8 @@ const VERSION = {
75113
}
76114

77115
module.exports = {
78-
EXTEND
116+
EXTEND,
117+
NEXT_TICK,
118+
SET,
119+
DELETE
79120
}

logfunctions/logglobalapi.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ module.exports = {
88
${chalk.green('Category:')} ${obj.category}
99
${chalk.green('Name:')} ${obj.name + '\n'}
1010
* Arguments:
11-
${obj.arguments.map(arg => {
12-
return `* ${args(arg)}`
13-
})}
14-
11+
${obj.arguments.map((arg, index) => {
12+
return `${index+1} ${args(arg)} `
13+
}).join(" ")}
14+
${obj.returns ? `* Returns: ${obj.returns}` : ''}
1515
* Usage: ${obj.usage}
16-
* Example: ${obj.example}
16+
${obj.example ? `* Example: ${obj.example}` : ''}
1717
`
1818
)
1919
}

vue-help.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,25 @@ V.command('productionTip', 'Outputs "Global Config: #productionTip"').action(fun
6666
// Global API
6767

6868
V.command('extend', 'Outputs "Global API: #Vue.extend(options)"').action(function(args, callback){
69-
const ex = ga[0]
70-
this.log(LGA.logGlobalAPI(ex))
69+
const ext = ga[0]
70+
this.log(LGA.logGlobalAPI(ext))
71+
callback()
72+
})
73+
74+
V.command('nextTick', 'Outputs "Global API: #Vue.nextTick([callback,context])"').action(function(args, callback){
75+
const nextTick = ga[1]
76+
this.log(LGA.logGlobalAPI(nextTick))
77+
callback()
78+
})
79+
80+
V.command('set', 'Outputs "Global API: #Vue.set(target,key,value)"').action(function(args, callback){
81+
const st = ga[2]
82+
this.log(LGA.logGlobalAPI(st))
83+
callback()
84+
})
85+
86+
V.command('delete', 'Outputs "Global API: #Vue.delete(target,key)"').action(function(args, callback){
87+
const dlt = ga[3]
88+
this.log(LGA.logGlobalAPI(dlt))
7189
callback()
7290
})

0 commit comments

Comments
 (0)