UNPKG

4.98 kBMarkdownView Raw
1Public Properties & Methods
2==============================
3
4Some useful vConsole properties and methods are available for plugin development.
5
6## Properties
7
8
9### vConsole.version
10
11The current version of vConsole.
12
13- Readonly
14- Type: string
15
16Example:
17
18```javascript
19vConsole.version // => "3.4.1"
20```
21
22
23### vConsole.option
24
25A configuration object.
26
27- Writable
28- Type: object
29
30Key | Type | Optional | Default value | Description
31--------------------- | -------- | -------- | ------------------------------------------- | -------------------
32defaultPlugins | Array | true | ['system', 'network', 'element', 'storage'] | Listed built-in plugins will be inited and loaded into vConsole.
33onReady | Function | true | | Trigger after vConsole is inited and default plugins is loaded.
34onClearLog | Function | true | | Trigger after click "Clear" button in Log and System panel.
35maxLogNumber | Number | true | 1000 | Overflow logs will be removed from log tabs.
36disableLogScrolling | Boolean | true | | If `false`, panel will not scroll to bottom while printing new logs.
37theme | String | true | 'light' | Theme mode, 'light' | 'dark'.
38
39Example:
40
41```javascript
42// get
43vConsole.option // => {...}
44// set
45vConsole.setOption('maxLogNumber', 5000);
46// or:
47vConsole.setOption({maxLogNumber: 5000});
48```
49
50
51### vConsole.activedTab
52
53The actived tab's plugin id.
54
55- Readonly
56- Type: string
57- Default: "default"
58
59Example:
60
61```javascript
62vConsole.activedTab // => "system"
63```
64
65
66### vConsole.tabList
67
68A list of installed tabs' plugin id.
69
70- Readonly
71- Type: array(string)
72
73Example:
74
75```javascript
76vConsole.tabList // => ["default", "system"]
77```
78
79
80### vConsole.$dom
81
82vConsole's HTML element.
83
84- Type: HTMLDivElement
85
86
87
88## Methods
89
90
91### vConsole.setOption(keyOrObj[, value])
92
93Update `vConsole.option`.
94
95##### Parameters:
96- (required) keyOrObj: The key of option, or a key-value object.
97- (optional) value: The value of an option.
98
99##### Return:
100- None
101
102##### Example:
103
104```javascript
105vConsole.setOption('maxLogNumber', 5000);
106// or:
107vConsole.setOption({maxLogNumber: 5000});
108```
109
110
111### vConsole.setSwitchPosition(x, y)
112
113Update the position of switch button.
114
115##### Parameters:
116- (required) x: X coordinate, the origin of the coordinate is at the bottom right corner of the screen.
117- (required) y: Y coordinate, the origin of the coordinate is at the bottom right corner of the screen.
118
119##### Return:
120- None
121
122##### Example:
123
124```javascript
125vConsole.setSwitchPosition(20, 20);
126```
127
128
129### vConsole.destroy()
130
131Destroy an vConsole instance object and remove vConsole panel from document.
132
133##### Parameters:
134- None
135
136##### Return:
137- None
138
139##### Example:
140
141```javascript
142var vConsole = new VConsole();
143// ... do something
144vConsole.destroy();
145```
146
147
148### vConsole.addPlugin(plugin)
149
150Add a new plugin to vConsole. Duplicate plugin will be ignored.
151
152##### Parameters:
153- (required) plugin: An VConsolePlugin object.
154
155##### Return:
156- Boolean: `true` for success, `false` for failure.
157
158##### Example:
159
160```javascript
161var myPlugin = new VConsolePlugin('my_plugin', 'My Plugin');
162vConsole.addPlugin(myPlugin);
163```
164
165
166### vConsole.removePlugin(pluginID)
167
168Remove an existing plugin.
169
170##### Parameters:
171- (required) pluginID: A string, plugin's id.
172
173##### Return:
174- Boolean: `true` for success, `false` for failure.
175
176##### Example:
177
178```javascript
179vConsole.removePlugin('my_plugin');
180```
181
182
183### vConsole.showTab(pluginID)
184
185Activating a tab according to its plugin id.
186
187Plugin event `hide` will be triggered for previous actived tab, and `show` for current actived tab.
188
189##### Parameters:
190- (required) pluginID: A string, tab's plugin id.
191
192##### Return:
193- None
194
195##### Example:
196
197```javascript
198vConsole.showTab("system"); // show System tab
199```
200
201
202### vConsole.show()
203
204Show vConsole panel. This method will trigger plugin event `showConsole`.
205
206##### Parameters:
207- None
208
209##### Return:
210- None
211
212##### Example:
213
214```javascript
215vConsole.show();
216```
217
218
219### vConsole.hide()
220
221Hide vConsole panel. This method will trigger plugin event `hideConsole`.
222
223##### Parameters:
224- None
225
226##### Return:
227- None
228
229##### Example:
230
231```javascript
232vConsole.hide();
233```
234
235
236### vConsole.showSwitch()
237
238Show vConsole switch button.
239
240##### Parameters:
241- None
242
243##### Return:
244- None
245
246##### Example:
247
248```javascript
249vConsole.showSwitch();
250```
251
252
253### vConsole.hideSwitch()
254
255Hide vConsole switch button.
256
257After the button is hidden, the user will not be able to call vConsole manually. The button or panel must be shown programmably via `vConsole.showSwitch()` or `vConsole.show()`.
258
259##### Parameters:
260- None
261
262##### Return:
263- None
264
265##### Example:
266
267```javascript
268vConsole.hideSwitch();
269```
270
271
272[Back to Index](./a_doc_index.md)
\No newline at end of file