Public Properties & Methods

Some useful vConsole properties and methods are available for plugin development.

Properties

vConsole.version

The current version of vConsole.

  • Readonly
  • Type: string

Example:

  1. vConsole.version // => "3.1.0"

vConsole.option

A configuration object.

  • Writable
  • Type: object
Key Type Optional Default value Description
defaultPlugins Array true [‘system’, ‘network’, ‘element’, ‘storage’] Listed built-in plugins will be inited and loaded into vConsole.
onReady Function true Trigger after vConsole is inited and default plugins is loaded.
onClearLog Function true Trigger after click “Clear” button in Log and System panel.
maxLogNumber Number true 1000 Overflow logs will be removed from log tabs.
disableLogScrolling Boolean true If false, panel will not scroll to bottom while printing new logs.

Example:

  1. // get
  2. vConsole.option // => {...}
  3. // set
  4. vConsole.setOption('maxLogNumber', 5000);
  5. // or:
  6. vConsole.setOption({maxLogNumber: 5000});

vConsole.activedTab

The actived tab’s plugin id.

  • Readonly
  • Type: string
  • Default: “default”

Example:

  1. vConsole.activedTab // => "system"

vConsole.tabList

A list of installed tabs’ plugin id.

  • Readonly
  • Type: array(string)

Example:

  1. vConsole.tabList // => ["default", "system"]

vConsole.$dom

vConsole’s HTML element.

  • Type: HTMLDivElement

Methods

vConsole.setOption(keyOrObj[, value])

Update vConsole.option.

Parameters:
  • (required) keyOrObj: The key of option, or a key-value object.
  • (optional) value: The value of an option.
Return:
  • None
Example:
  1. vConsole.setOption('maxLogNumber', 5000);
  2. // or:
  3. vConsole.setOption({maxLogNumber: 5000});

vConsole.destroy()

Destroy an vConsole instance object and remove vConsole panel from document.

Parameters:
  • None
Return:
  • None
Example:
  1. var vConsole = new VConsole();
  2. // ... do something
  3. vConsole.destroy();

vConsole.addPlugin(plugin)

Add a new plugin to vConsole. Duplicate plugin will be ignored.

Parameters:
  • (required) plugin: An VConsolePlugin object.
Return:
  • Boolean: true for success, false for failure.
Example:
  1. var myPlugin = new VConsolePlugin('my_plugin', 'My Plugin');
  2. vConsole.addPlugin(myPlugin);

vConsole.removePlugin(pluginID)

Remove an existing plugin.

Parameters:
  • (required) pluginID: A string, plugin’s id.
Return:
  • Boolean: true for success, false for failure.
Example:
  1. vConsole.removePlugin('my_plugin');

vConsole.showTab(pluginID)

Activating a tab according to its plugin id.

Plugin event hide will be triggered for previous actived tab, and show for current actived tab.

Parameters:
  • (required) pluginID: A string, tab’s plugin id.
Return:
  • None
Example:
  1. vConsole.showTab("system"); // show System tab

vConsole.show()

Show vConsole panel. This method will trigger plugin event showConsole.

Parameters:
  • None
Return:
  • None
Example:
  1. vConsole.show();

vConsole.hide()

Hide vConsole panel. This method will trigger plugin event hideConsole.

Parameters:
  • None
Return:
  • None
Example:
  1. vConsole.hide();

vConsole.showSwitch()

Show vConsole switch button.

Parameters:
  • None
Return:
  • None
Example:
  1. vConsole.showSwitch();

vConsole.hideSwitch()

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().

Parameters:
  • None
Return:
  • None
Example:
  1. vConsole.hideSwitch();

Back to Index