1 | Public Properties & Methods
|
2 | ==============================
|
3 |
|
4 | Some useful vConsole properties and methods are available for plugin development.
|
5 |
|
6 | ## Properties
|
7 |
|
8 |
|
9 | ### vConsole.version
|
10 |
|
11 | The current version of vConsole.
|
12 |
|
13 | - Readonly
|
14 | - Type: string
|
15 |
|
16 | Example:
|
17 |
|
18 | ```javascript
|
19 | vConsole.version // => "3.4.1"
|
20 | ```
|
21 |
|
22 |
|
23 | ### vConsole.option
|
24 |
|
25 | A configuration object.
|
26 |
|
27 | - Writable
|
28 | - Type: object
|
29 |
|
30 | Key | Type | Optional | Default value | Description
|
31 | --------------------- | -------- | -------- | ------------------------------------------- | -------------------
|
32 | defaultPlugins | Array | true | ['system', 'network', 'element', 'storage'] | Listed built-in plugins will be inited and loaded into vConsole.
|
33 | onReady | Function | true | | Trigger after vConsole is inited and default plugins is loaded.
|
34 | onClearLog | Function | true | | Trigger after click "Clear" button in Log and System panel.
|
35 | maxLogNumber | Number | true | 1000 | Overflow logs will be removed from log tabs.
|
36 | disableLogScrolling | Boolean | true | | If `false`, panel will not scroll to bottom while printing new logs.
|
37 | theme | String | true | 'light' | Theme mode, 'light' | 'dark'.
|
38 |
|
39 | Example:
|
40 |
|
41 | ```javascript
|
42 | // get
|
43 | vConsole.option // => {...}
|
44 | // set
|
45 | vConsole.setOption('maxLogNumber', 5000);
|
46 | // or:
|
47 | vConsole.setOption({maxLogNumber: 5000});
|
48 | ```
|
49 |
|
50 |
|
51 | ### vConsole.activedTab
|
52 |
|
53 | The actived tab's plugin id.
|
54 |
|
55 | - Readonly
|
56 | - Type: string
|
57 | - Default: "default"
|
58 |
|
59 | Example:
|
60 |
|
61 | ```javascript
|
62 | vConsole.activedTab // => "system"
|
63 | ```
|
64 |
|
65 |
|
66 | ### vConsole.tabList
|
67 |
|
68 | A list of installed tabs' plugin id.
|
69 |
|
70 | - Readonly
|
71 | - Type: array(string)
|
72 |
|
73 | Example:
|
74 |
|
75 | ```javascript
|
76 | vConsole.tabList // => ["default", "system"]
|
77 | ```
|
78 |
|
79 |
|
80 | ### vConsole.$dom
|
81 |
|
82 | vConsole's HTML element.
|
83 |
|
84 | - Type: HTMLDivElement
|
85 |
|
86 |
|
87 |
|
88 | ## Methods
|
89 |
|
90 |
|
91 | ### vConsole.setOption(keyOrObj[, value])
|
92 |
|
93 | Update `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
|
105 | vConsole.setOption('maxLogNumber', 5000);
|
106 | // or:
|
107 | vConsole.setOption({maxLogNumber: 5000});
|
108 | ```
|
109 |
|
110 |
|
111 | ### vConsole.setSwitchPosition(x, y)
|
112 |
|
113 | Update 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
|
125 | vConsole.setSwitchPosition(20, 20);
|
126 | ```
|
127 |
|
128 |
|
129 | ### vConsole.destroy()
|
130 |
|
131 | Destroy 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
|
142 | var vConsole = new VConsole();
|
143 | // ... do something
|
144 | vConsole.destroy();
|
145 | ```
|
146 |
|
147 |
|
148 | ### vConsole.addPlugin(plugin)
|
149 |
|
150 | Add 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
|
161 | var myPlugin = new VConsolePlugin('my_plugin', 'My Plugin');
|
162 | vConsole.addPlugin(myPlugin);
|
163 | ```
|
164 |
|
165 |
|
166 | ### vConsole.removePlugin(pluginID)
|
167 |
|
168 | Remove 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
|
179 | vConsole.removePlugin('my_plugin');
|
180 | ```
|
181 |
|
182 |
|
183 | ### vConsole.showTab(pluginID)
|
184 |
|
185 | Activating a tab according to its plugin id.
|
186 |
|
187 | Plugin 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
|
198 | vConsole.showTab("system"); // show System tab
|
199 | ```
|
200 |
|
201 |
|
202 | ### vConsole.show()
|
203 |
|
204 | Show 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
|
215 | vConsole.show();
|
216 | ```
|
217 |
|
218 |
|
219 | ### vConsole.hide()
|
220 |
|
221 | Hide 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
|
232 | vConsole.hide();
|
233 | ```
|
234 |
|
235 |
|
236 | ### vConsole.showSwitch()
|
237 |
|
238 | Show vConsole switch button.
|
239 |
|
240 | ##### Parameters:
|
241 | - None
|
242 |
|
243 | ##### Return:
|
244 | - None
|
245 |
|
246 | ##### Example:
|
247 |
|
248 | ```javascript
|
249 | vConsole.showSwitch();
|
250 | ```
|
251 |
|
252 |
|
253 | ### vConsole.hideSwitch()
|
254 |
|
255 | Hide vConsole switch button.
|
256 |
|
257 | After 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
|
268 | vConsole.hideSwitch();
|
269 | ```
|
270 |
|
271 |
|
272 | [Back to Index](./a_doc_index.md) |
\ | No newline at end of file |