Some useful vConsole properties and methods are available for plugin development.
Get the current vConsole instance, which is a singleton instance. Returns undefined
if it has not been instantiated.
The prototype of custom plugin. See Plugin: Getting Started for details.
The current version of vConsole.
Example:
vConsole.version // => "3.11.0"
A configuration object.
Key | Type | Optional | Default value | Description |
---|---|---|---|---|
defaultPlugins | Array(String) | true | ['system', 'network', 'element', 'storage'] | Listed built-in plugins will be inited and loaded into vConsole. |
pluginOrder | Array(String) | true | [] | Plugin panels will be sorted as this list. Plugin not listed will be put last. |
onReady | Function | true | Trigger after vConsole is inited and default plugins is loaded. | |
disableLogScrolling | Boolean | true | If false , panel will not scroll to bottom while printing new logs. |
|
theme | String | true | 'light' | Theme mode, 'light' |
target | String, HTMLElement | true | document.documentElement |
An HTMLElement or CSS selector string to render to. |
log.maxLogNumber | Number | true | 1000 | Overflow logs will be removed from log panels. |
log.showTimestamps | Boolean | true | false | Display timestamps of logs. |
network.maxNetworkNumber | Number | true | 1000 | Overflow requests will be removed from Netowrk panel. |
network.ignoreUrlRegExp | RegExp | true | Skip the requests which url match the RegExp. | |
storage.defaultStorages | Array | true | ['cookies', 'localStorage', 'sessionStorage'] | Listed storage(s) will be available in Storage panel. |
Example:
// get
vConsole.option // => {...}
// set single key only
vConsole.setOption('log.maxLogNumber', 5000);
// overwrite 'log' object
vConsole.setOption({ log: { maxLogNumber: 5000 } });
Update vConsole.option
.
vConsole.setOption('maxLogNumber', 5000);
// or:
vConsole.setOption({maxLogNumber: 5000});
Update the position of switch button.
vConsole.setSwitchPosition(20, 20);
Destroy an vConsole instance object and remove vConsole panel from document.
var vConsole = new VConsole();
// ... do something
vConsole.destroy();
Add a new plugin to vConsole. Duplicate plugin will be ignored.
true
for success, false
for failure.var myPlugin = new VConsolePlugin('my_plugin', 'My Plugin');
vConsole.addPlugin(myPlugin);
Remove an existing plugin.
true
for success, false
for failure.vConsole.removePlugin('my_plugin');
Activating a panel according to its plugin id.
Plugin event hide
will be triggered for previous actived panel, and show
for current actived panel.
vConsole.showPlugin("system"); // show System panel
Show vConsole panel. This method will trigger plugin event showConsole
.
vConsole.show();
Hide vConsole panel. This method will trigger plugin event hideConsole
.
vConsole.hide();
Show vConsole switch button.
vConsole.showSwitch();
Hide vConsole switch button.
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()
.
vConsole.hideSwitch();
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。