Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat small program basic functions


May 18, 2021 WeChat Mini Program Development Document



Object wx

A global object of the program API that is used to host a small program capability-related API.

Object wx.env

The small program environment variable object

String wx.env.USER_DATA_PATH

The user directory path in the file system


console

Print the logs to the debug panel. C onsole is a global object that can be accessed directly. In the WeChat client, output the logs to vConsole.

Method:

console.debug()

Print the debug log to the debug panel

Parameters

any ... args

Log content, can have as many as anywhere.


console.error()

Print the error log to the debug panel

Parameters

any ... args

Log content, can have as many as anywhere.


console.group(string label)

Create a new grouping in the debug panel. T he output is then indented to indicate that the content belongs to the current grouping. The group ends after calling console.groupEnd.

Parameters

string label

Group tags, optional.

Attention

Valid only in tools, empty function implementation in vConsole.


console.groupEnd()

Ends the grouping created by console.group

Attention

Valid only in tools, empty function implementation in vConsole.


console.info()

Print the info log to the debug panel

Parameters

any ... args

Log content, can have as many as anywhere.


console.log()

Print the log log to the debug panel

Parameters

any ... args

Log content, can have as many as anywhere


console.warn()

Print the warn log to the debug panel

Parameters

any ... args

Log content, can have as many as anywhere.


number setTimeout(function callback, number delay, any rest)

Set a timer. A registered callback function is executed after the time expires

Parameters

function callback

Callback function

number delay

Delayed time, the call to the function occurs after that delay, in ms.

any rest

Additional parameters such as param1, param2, ..., paramN, which are passed as arguments to the callback function.

Returns a value

number

The number of the timer. This value can be passed to clearTimeout to cancel the time.


clearTimeout(number timeoutID)

Cancel the timer set by setTimeout.

Parameters

number timeoutID

The ID of the timer to cancel


number setInterval(function callback, number delay, any rest)

Set a timer. The registered callback function is executed in milliseconds for the specified period

Parameters

function callback

Callback function

number delay

The interval between the execution callback functions, in ms.

any rest

Additional parameters such as param1, param2, ..., paramN, which are passed as arguments to the callback function.

Returns a value

number

The number of the timer. This value can be passed to clearInterval to cancel the time.


clearInterval(number intervalID)

Cancel the timer set by setInterval.

Parameters

number intervalID

The ID of the timer to cancel