提交 15adcfd6 编写于 作者: O openharmony_ci 提交者: Gitee

!1025 新增英文文档&部分中文文档修正

Merge pull request !1025 from zengyawen/master
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
- [JavaScript-based Web-like Development Paradigm](arkui-js/Readme-EN.md) - [JavaScript-based Web-like Development Paradigm](arkui-js/Readme-EN.md)
- [TypeScript-based Declarative Development Paradigm](arkui-ts/Readme-EN.md) - [TypeScript-based Declarative Development Paradigm](arkui-ts/Readme-EN.md)
- [APIs](apis/apis.md) - [APIs](apis/Readme-EN.md)
\ No newline at end of file
# APIs # APIs
- [Console Logs](console-logs.md) - Resource Management
- [HiAppEvent](hiappevent.md) - [Resource Manager](js-apis-resource-manager.md)
- [Page Routing](page-routing.md) - [Internationalization \(intl\) ](js-apis-intl.md)
- [Pop-up Window](pop-up-window.md) - [Internationalization \(i18n\) ](js-apis-i18n.md)
- [Timer](timer.md) - Media
- [Audio Management](js-apis-audio.md) - [Audio Management](js-apis-audio.md)
- [Audio Playback](audio-playback.md) - [Media Playback and Recording](js-apis-media.md)
- [Device Information](device-information.md) - Data Management
- [System Attribute](system-attribute.md) - [File Management](js-apis-fileio.md)
- [Battery and Charging](battery-and-charging.md) - [Lightweight Storage](js-apis-data-storage.md)
- [Screen Brightness](screen-brightness.md) - [Distributed Data Management](js-apis-distributed-data.md)
- [Globalization](globalization.md) - [Relational Database](js-apis-data-rdb.md)
- [Resource Management](resource-management.md) - [Result Set](js-apis-data-resultset.md)
- [Updater](updater.md) - [DataAbilityPredicates](js-apis-data-ability.md)
- Account Management
- [Distributed Account Management](js-apis-distributed-account.md)
- Telephony Service
- [Call](js-apis-call.md)
- [SMS](js-apis-sms.md)
- [SIM Management](js-apis-sim.md)
- [Radio](js-apis-radio.md)
- Device Management
- [Sensors](js-apis-sensor.md)
- [Vibration](js-apis-vibrator.md)
- [Brightness](js-apis-brightness.md)
- [Battery Info](js-apis-battery-info.md)
- [Power Management](js-apis-power.md)
- [Running Lock](js-apis-runninglock.md)
- [Device Info](js-apis-device-info.md)
- [systemParameter](js-apis-system-parameter.md)
- [Device Management](js-apis-device-manager.md)
- [Window](js-apis-window.md)
- [Display](js-apis-display.md)
- Basic Features
- [Application Context](js-apis-basic-features-app-context.md)
- [Console Logs](js-apis-basic-features-logs.md)
- [Page Routing](js-apis-basic-features-routes.md)
- [Pop-up Window](js-apis-basic-features-pop-up.md)
- [Application Configuration](js-apis-basic-features-configuration.md)
- [Timer](js-apis-basic-features-timer.md)
- [Setting the System Time](js-apis-system-time.md)
- [Animation](js-apis-basic-features-animator.md)
- [HiAppEvent](js-apis-hiappevent.md)
- [Performance Tracing](js-apis-bytrace.md)
- Language Base Class Library
- [Obtaining Process Information](js-apis-process.md)
- [URL String Parsing](js-apis-url.md)
- [String Encoding and Decoding](js-apis-util.md)
- [Worker Startup](js-apis-worker.md)
# APIs<a name="EN-US_TOPIC_0000001162494631"></a>
- **[Console Logs](console-logs.md)**
- **[HiAppEvent](hiappevent.md)**
- **[Page Routing](page-routing.md)**
- **[Pop-up Window](pop-up-window.md)**
- **[Timer](timer.md)**
- **[Audio Management](js-apis-audio.md)**
- **[Audio Playback](audio-playback.md)**
- **[Device Information](device-information.md)**
- **[System Attribute](system-attribute.md)**
- **[Battery and Charging](battery-and-charging.md)**
- **[Screen Brightness](screen-brightness.md)**
- **[Globalization](globalization.md)**
- **[Resource Management](resource-management.md)**
- **[Updater](updater.md)**
# Audio Playback<a name="EN-US_TOPIC_0000001103383404"></a>
## Modules to Import<a name="s56d19203690d4782bfc74069abb6bd71"></a>
```
import audio from '@ohos.multimedia.media';
```
## Required Permissions<a name="section11257113618419"></a>
None
## Methods<a name="section125675489541"></a>
## createAudioPlayer\(\)<a name="section582314017253"></a>
Creates an **AudioPlayer** instance to control audio playback.
**Return Values**
<a name="table482411406254"></a>
<table><thead align="left"><tr id="row138241940172518"><th class="cellrowborder" valign="top" width="16.05%" id="mcps1.1.3.1.1"><p id="p28256407257"><a name="p28256407257"></a><a name="p28256407257"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="83.95%" id="mcps1.1.3.1.2"><p id="p1582544017256"><a name="p1582544017256"></a><a name="p1582544017256"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row0825540192520"><td class="cellrowborder" valign="top" width="16.05%" headers="mcps1.1.3.1.1 "><p id="p482574042511"><a name="p482574042511"></a><a name="p482574042511"></a><a href="#section5174142818365">AudioPlayer</a></p>
</td>
<td class="cellrowborder" valign="top" width="83.95%" headers="mcps1.1.3.1.2 "><p id="p14825194014258"><a name="p14825194014258"></a><a name="p14825194014258"></a>Returns the <strong id="b1322434113810"><a name="b1322434113810"></a><a name="b1322434113810"></a>AudioPlayer</strong> instance if the operation is successful; returns <strong id="b114701838153811"><a name="b114701838153811"></a><a name="b114701838153811"></a>null</strong> otherwise.</p>
</td>
</tr>
</tbody>
</table>
**Example**
```
var audioplayer = audio.createAudioPlayer();
```
## Appendixes<a name="section1933416317165"></a>
## AudioPlayer<a name="section5174142818365"></a>
Represents an audio player.
### Attributes<a name="section4947115405"></a>
<a name="table92548495595"></a>
<table><thead align="left"><tr id="row132541749175917"><th class="cellrowborder" valign="top" width="15.8015801580158%" id="mcps1.1.6.1.1"><p id="p925404965919"><a name="p925404965919"></a><a name="p925404965919"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.591959195919593%" id="mcps1.1.6.1.2"><p id="p325464914599"><a name="p325464914599"></a><a name="p325464914599"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="7.660766076607661%" id="mcps1.1.6.1.3"><p id="p025484918596"><a name="p025484918596"></a><a name="p025484918596"></a>Readable</p>
</th>
<th class="cellrowborder" valign="top" width="8.29082908290829%" id="mcps1.1.6.1.4"><p id="p025414499590"><a name="p025414499590"></a><a name="p025414499590"></a>Writable</p>
</th>
<th class="cellrowborder" valign="top" width="48.65486548654865%" id="mcps1.1.6.1.5"><p id="p20254134925912"><a name="p20254134925912"></a><a name="p20254134925912"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row18254849155915"><td class="cellrowborder" valign="top" width="15.8015801580158%" headers="mcps1.1.6.1.1 "><p id="p20254204935915"><a name="p20254204935915"></a><a name="p20254204935915"></a>src</p>
</td>
<td class="cellrowborder" valign="top" width="19.591959195919593%" headers="mcps1.1.6.1.2 "><p id="p1525413497591"><a name="p1525413497591"></a><a name="p1525413497591"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="7.660766076607661%" headers="mcps1.1.6.1.3 "><p id="p8254749195914"><a name="p8254749195914"></a><a name="p8254749195914"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="8.29082908290829%" headers="mcps1.1.6.1.4 "><p id="p5255549115910"><a name="p5255549115910"></a><a name="p5255549115910"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="48.65486548654865%" headers="mcps1.1.6.1.5 "><p id="p72551449145914"><a name="p72551449145914"></a><a name="p72551449145914"></a>URI of the audio resources</p>
</td>
</tr>
<tr id="row10255134945917"><td class="cellrowborder" valign="top" width="15.8015801580158%" headers="mcps1.1.6.1.1 "><p id="p82551349125910"><a name="p82551349125910"></a><a name="p82551349125910"></a>loop</p>
</td>
<td class="cellrowborder" valign="top" width="19.591959195919593%" headers="mcps1.1.6.1.2 "><p id="p18255154913598"><a name="p18255154913598"></a><a name="p18255154913598"></a>boolean</p>
</td>
<td class="cellrowborder" valign="top" width="7.660766076607661%" headers="mcps1.1.6.1.3 "><p id="p525516497595"><a name="p525516497595"></a><a name="p525516497595"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="8.29082908290829%" headers="mcps1.1.6.1.4 "><p id="p2025504917593"><a name="p2025504917593"></a><a name="p2025504917593"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="48.65486548654865%" headers="mcps1.1.6.1.5 "><p id="p7255194925919"><a name="p7255194925919"></a><a name="p7255194925919"></a>Whether to loop audio playback</p>
</td>
</tr>
<tr id="row18256049165911"><td class="cellrowborder" valign="top" width="15.8015801580158%" headers="mcps1.1.6.1.1 "><p id="p2256154919590"><a name="p2256154919590"></a><a name="p2256154919590"></a>currentTime</p>
</td>
<td class="cellrowborder" valign="top" width="19.591959195919593%" headers="mcps1.1.6.1.2 "><p id="p10256849165915"><a name="p10256849165915"></a><a name="p10256849165915"></a>number</p>
</td>
<td class="cellrowborder" valign="top" width="7.660766076607661%" headers="mcps1.1.6.1.3 "><p id="p19256149155915"><a name="p19256149155915"></a><a name="p19256149155915"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="8.29082908290829%" headers="mcps1.1.6.1.4 "><p id="p3256174935919"><a name="p3256174935919"></a><a name="p3256174935919"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="48.65486548654865%" headers="mcps1.1.6.1.5 "><p id="p12256144995913"><a name="p12256144995913"></a><a name="p12256144995913"></a>Current playback position</p>
</td>
</tr>
<tr id="row11256144911598"><td class="cellrowborder" valign="top" width="15.8015801580158%" headers="mcps1.1.6.1.1 "><p id="p92561949125910"><a name="p92561949125910"></a><a name="p92561949125910"></a>duration</p>
</td>
<td class="cellrowborder" valign="top" width="19.591959195919593%" headers="mcps1.1.6.1.2 "><p id="p9256124914597"><a name="p9256124914597"></a><a name="p9256124914597"></a>number</p>
</td>
<td class="cellrowborder" valign="top" width="7.660766076607661%" headers="mcps1.1.6.1.3 "><p id="p1725654915911"><a name="p1725654915911"></a><a name="p1725654915911"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="8.29082908290829%" headers="mcps1.1.6.1.4 "><p id="p192562049125910"><a name="p192562049125910"></a><a name="p192562049125910"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="48.65486548654865%" headers="mcps1.1.6.1.5 "><p id="p125684995913"><a name="p125684995913"></a><a name="p125684995913"></a>Playback duration</p>
</td>
</tr>
<tr id="row6256149115920"><td class="cellrowborder" valign="top" width="15.8015801580158%" headers="mcps1.1.6.1.1 "><p id="p2256144918596"><a name="p2256144918596"></a><a name="p2256144918596"></a>state</p>
</td>
<td class="cellrowborder" valign="top" width="19.591959195919593%" headers="mcps1.1.6.1.2 "><p id="p9256144918593"><a name="p9256144918593"></a><a name="p9256144918593"></a><a href="#section5181155710523">AudioState</a></p>
</td>
<td class="cellrowborder" valign="top" width="7.660766076607661%" headers="mcps1.1.6.1.3 "><p id="p102563495592"><a name="p102563495592"></a><a name="p102563495592"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="8.29082908290829%" headers="mcps1.1.6.1.4 "><p id="p625620497594"><a name="p625620497594"></a><a name="p625620497594"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="48.65486548654865%" headers="mcps1.1.6.1.5 "><p id="p162571549195920"><a name="p162571549195920"></a><a name="p162571549195920"></a>Playback status</p>
</td>
</tr>
</tbody>
</table>
### play\(\)<a name="section964512672913"></a>
Starts audio playback.
**Example**
```
audioplayer.on('dataload', (err, action) => {
if (err) {
console.info('Error returned in the prepare() callback.');
return;
}
console.info('Start to play the audio.');
audioplayer.play();
};
audioplayer.on('play', (err, action) => {
if (err) {
console.info('Error returned in the play() callback.');
return;
}
console.info('Succeeded in playing the audio.');
};
audioplayer.src = 'common/mydream.mp3';
```
### pause\(\)<a name="section78173258296"></a>
Pauses audio playback.
**Example**
```
audioplayer.on('dataload', (err, action) => {
if (err) {
console.info('Error returned in the prepare() callback.');
return;
}
console.info('Start to play the audio.');
audioplayer.play();
}
audioplayer.on('play', (err, action) => {
if (err) {
console.info('Error returned in the play() callback.');
return;
}
console.info('Start to pause audio playback.');
audioplayer.pause();
};
audioplayer.on('pause', (err, action) => {
if (err) {
console.info('Error returned in the pause() callback.');
return;
}
console.info('Succeeded in pausing audio playback.');
};
audioplayer.src = 'common/mydream.mp3';
```
### stop\(\)<a name="section122114334296"></a>
Stops audio playback.
**Example**
```
audioplayer.on('dataload', (err, action) => {
if (err) {
console.info('Error returned in the prepare() callback.');
return;
}
console.info('Start to play the audio.');
audioplayer.play();
};
audioplayer.on('play', (err, action) => {
if (err) {
console.info('Error returned in the play() callback.');
return;
}
console.info('Start to pause audio playback.');
audioplayer.pause();
};
audioplayer.on('stop', (err, action) => {
if (err) {
console.info('Error returned in the stop() callback.');
return;
}
console.info('Succeeded in stopping audio playback.');
};
audioplayer.src = 'common/mydream.mp3';
```
### seek\(number\)<a name="section1387113816298"></a>
Goes to a specified playback position.
**Parameters**
<a name="table1442723852917"></a>
<table><thead align="left"><tr id="row84261138172911"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p204261938182919"><a name="p204261938182919"></a><a name="p204261938182919"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="12.02%" id="mcps1.1.5.1.2"><p id="p1342683842920"><a name="p1342683842920"></a><a name="p1342683842920"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="7.5200000000000005%" id="mcps1.1.5.1.3"><p id="p134260383297"><a name="p134260383297"></a><a name="p134260383297"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="62.89%" id="mcps1.1.5.1.4"><p id="p442663832912"><a name="p442663832912"></a><a name="p442663832912"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row18427738202910"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p184261338192913"><a name="p184261338192913"></a><a name="p184261338192913"></a>timeMs</p>
</td>
<td class="cellrowborder" valign="top" width="12.02%" headers="mcps1.1.5.1.2 "><p id="p1242643819295"><a name="p1242643819295"></a><a name="p1242643819295"></a>number</p>
</td>
<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.5.1.3 "><p id="p44261838112918"><a name="p44261838112918"></a><a name="p44261838112918"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="62.89%" headers="mcps1.1.5.1.4 "><p id="p16427163812913"><a name="p16427163812913"></a><a name="p16427163812913"></a>Target playback position</p>
</td>
</tr>
</tbody>
</table>
**Example**
```
audioplayer.on('dataload', (err, action) => {
if (err) {
console.info('Error returned in the prepare() callback.');
return;
}
console.info('Start to play the audio.');
audioplayer.play();
};
audioplayer.on('play', (err, action) => {
if (err) {
console.info('Error returned in the play() callback.');
return;
}
console.info('Succeeded in playing the audio.')
};
audioplayer.on('timeUpdate', (seekTime, action) => {
console.info('Seek time returned in the seek() callback: ' + seekTime);
var newTime = audioplayer.currenTime;
if(newTime == 30000) {
console.info('Seek succeeded. New time: ' + newTime);
} else {
console.info('Seek failed.');
}
};
audioplayer.src = 'common/mydream.mp3';
audioplayer.seek(30000);
```
### setVolume\(number\)<a name="section164235176552"></a>
Sets the volume.
**Parameters**
<a name="table1242391713555"></a>
<table><thead align="left"><tr id="row14424217195517"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p1424917135519"><a name="p1424917135519"></a><a name="p1424917135519"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="12.02%" id="mcps1.1.5.1.2"><p id="p10424121795520"><a name="p10424121795520"></a><a name="p10424121795520"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="7.5200000000000005%" id="mcps1.1.5.1.3"><p id="p1042415178559"><a name="p1042415178559"></a><a name="p1042415178559"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="62.89%" id="mcps1.1.5.1.4"><p id="p13424717125513"><a name="p13424717125513"></a><a name="p13424717125513"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row13424171745513"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p204241517125517"><a name="p204241517125517"></a><a name="p204241517125517"></a>vol</p>
</td>
<td class="cellrowborder" valign="top" width="12.02%" headers="mcps1.1.5.1.2 "><p id="p18424121755517"><a name="p18424121755517"></a><a name="p18424121755517"></a>number</p>
</td>
<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.5.1.3 "><p id="p2042417176554"><a name="p2042417176554"></a><a name="p2042417176554"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="62.89%" headers="mcps1.1.5.1.4 "><p id="p9424171717557"><a name="p9424171717557"></a><a name="p9424171717557"></a>Volume to set. The value ranges from 0 to 1.</p>
</td>
</tr>
</tbody>
</table>
**Example**
```
audioplayer.on('dataload', (err, action) => {
if (err) {
console.error('Error returned in the prepare() callback.');
return;
}
console.info('Start to play the audio.');
audioplayer.play();
};
audioplayer.on('play', (err, action) => {
if (err) {
console.error('Error returned in the play() callback.');
return;
}
console.info('Succeeded in playing the audio.')
};
audioplayer.on('volumeChange', (err, action) => {
if (err) {
console.error('Error returned in the setVolume() callback.');
return;
}
console.info('Playback volume changed.');
};
audioplayer.src = 'common/mydream.mp3';
audioplayer.setVolume(0.5);
```
### reset\(\)<sup>7+</sup><a name="section1473283011356"></a>
Switches the audio resource to be played.
**Example**
```
audioplayer.on('dataload', (err, action) => {
if (err) {
console.error('Error returned in the prepare() callback.');
return;
}
console.info('Start to reset audio playback.');
audioplayer.reset();
};
audioplayer.on('reset', (err, action) => {
if (err) {
console.error('Error returned in the reset() callback.');
return;
}
console.info('Reset succeeded.');
};
audioplayer.src = 'common/mydream.mp3';
```
### release\(\)<a name="section9224621145512"></a>
Releases audio resources.
**Example**
```
audioplay.release();
```
### Events<a name="section5453721192911"></a>
### play<a name="section87307411494"></a>
Triggered when **play\(\)** is called
### pause<a name="section198217471590"></a>
Triggered when **pause\(\)** is called
### stop<a name="section437616531910"></a>
Triggered when **stop\(\)** is called
### dataLoad<a name="section982114219106"></a>
Triggered when audio data is loaded
### timeUpdate<a name="section13687114181014"></a>
Triggered when the playback position changes
### volumeChange<a name="section139227715717"></a>
Triggered when playback volume changes
### finish<a name="section15181321181018"></a>
Triggered when playback is finished
### error<a name="section5593132921016"></a>
Triggered when a playback error occurs
<a name="table24591722143619"></a>
<table><thead align="left"><tr id="row1945962219364"><th class="cellrowborder" valign="top" width="24.060000000000002%" id="mcps1.1.4.1.1"><p id="p84591522103610"><a name="p84591522103610"></a><a name="p84591522103610"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="25.25%" id="mcps1.1.4.1.2"><p id="p11459102243616"><a name="p11459102243616"></a><a name="p11459102243616"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="50.690000000000005%" id="mcps1.1.4.1.3"><p id="p14591922113616"><a name="p14591922113616"></a><a name="p14591922113616"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row2459622183611"><td class="cellrowborder" valign="top" width="24.060000000000002%" headers="mcps1.1.4.1.1 "><p id="p17338122234119"><a name="p17338122234119"></a><a name="p17338122234119"></a>callback</p>
</td>
<td class="cellrowborder" valign="top" width="25.25%" headers="mcps1.1.4.1.2 "><p id="p174601822193612"><a name="p174601822193612"></a><a name="p174601822193612"></a>ErrorCallback</p>
</td>
<td class="cellrowborder" valign="top" width="50.690000000000005%" headers="mcps1.1.4.1.3 "><p id="p7460222123612"><a name="p7460222123612"></a><a name="p7460222123612"></a>Callback function for handling this event</p>
</td>
</tr>
</tbody>
</table>
## AudioState<a name="section5181155710523"></a>
Describes playback status.
<a name="table919114616314"></a>
<table><thead align="left"><tr id="row31917610318"><th class="cellrowborder" valign="top" width="33.739999999999995%" id="mcps1.1.3.1.1"><p id="p219196531"><a name="p219196531"></a><a name="p219196531"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="66.25999999999999%" id="mcps1.1.3.1.2"><p id="p14191563313"><a name="p14191563313"></a><a name="p14191563313"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row3427194315719"><td class="cellrowborder" valign="top" width="33.739999999999995%" headers="mcps1.1.3.1.1 "><p id="p642711431172"><a name="p642711431172"></a><a name="p642711431172"></a>idle</p>
</td>
<td class="cellrowborder" valign="top" width="66.25999999999999%" headers="mcps1.1.3.1.2 "><p id="p24281543777"><a name="p24281543777"></a><a name="p24281543777"></a>Audio playback is idle.</p>
</td>
</tr>
<tr id="row2019146539"><td class="cellrowborder" valign="top" width="33.739999999999995%" headers="mcps1.1.3.1.1 "><p id="p201913617311"><a name="p201913617311"></a><a name="p201913617311"></a>playing</p>
</td>
<td class="cellrowborder" valign="top" width="66.25999999999999%" headers="mcps1.1.3.1.2 "><p id="p81911362316"><a name="p81911362316"></a><a name="p81911362316"></a>The audio is being played.</p>
</td>
</tr>
<tr id="row11912612316"><td class="cellrowborder" valign="top" width="33.739999999999995%" headers="mcps1.1.3.1.1 "><p id="p9191136731"><a name="p9191136731"></a><a name="p9191136731"></a>paused</p>
</td>
<td class="cellrowborder" valign="top" width="66.25999999999999%" headers="mcps1.1.3.1.2 "><p id="p419166738"><a name="p419166738"></a><a name="p419166738"></a>Audio playback is paused.</p>
</td>
</tr>
<tr id="row111912617314"><td class="cellrowborder" valign="top" width="33.739999999999995%" headers="mcps1.1.3.1.1 "><p id="p9191156333"><a name="p9191156333"></a><a name="p9191156333"></a>stopped</p>
</td>
<td class="cellrowborder" valign="top" width="66.25999999999999%" headers="mcps1.1.3.1.2 "><p id="p2019215618316"><a name="p2019215618316"></a><a name="p2019215618316"></a>Audio playback is stopped.</p>
</td>
</tr>
</tbody>
</table>
# Console Logs<a name="EN-US_TOPIC_0000001115814846"></a>
## Module to Import<a name="en-us_topic_0000001058460515_s56d19203690d4782bfc74069abb6bd71"></a>
No module is required.
## Permission List<a name="en-us_topic_0000001058460515_section11257113618419"></a>
None
## Log Category<a name="en-us_topic_0000001058460515_s298a3cf59a3b470dbb0742706102ced7"></a>
Prints a log using **console.debug|log|info|warn|error\(message\)**.
- Parameter
<a name="en-us_topic_0000001058460515_t87748b0ba4e648079d53f9deccf4bfb2"></a>
<table><thead align="left"><tr id="en-us_topic_0000001058460515_rc5033ad045c14c2e806d59041aab002c"><th class="cellrowborder" valign="top" width="12%" id="mcps1.1.5.1.1"><p id="en-us_topic_0000001058460515_acf783ab6043e4ee1a7bb73b73a091e0b"><a name="en-us_topic_0000001058460515_acf783ab6043e4ee1a7bb73b73a091e0b"></a><a name="en-us_topic_0000001058460515_acf783ab6043e4ee1a7bb73b73a091e0b"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="9%" id="mcps1.1.5.1.2"><p id="en-us_topic_0000001058460515_a6736505551534b819d5a6376065a25f6"><a name="en-us_topic_0000001058460515_a6736505551534b819d5a6376065a25f6"></a><a name="en-us_topic_0000001058460515_a6736505551534b819d5a6376065a25f6"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9%" id="mcps1.1.5.1.3"><p id="en-us_topic_0000001058460515_ac15c2a3de0e046af917cf09b48b3b46d"><a name="en-us_topic_0000001058460515_ac15c2a3de0e046af917cf09b48b3b46d"></a><a name="en-us_topic_0000001058460515_ac15c2a3de0e046af917cf09b48b3b46d"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="70%" id="mcps1.1.5.1.4"><p id="en-us_topic_0000001058460515_aeb94b88e78974288bab1b4940b50c840"><a name="en-us_topic_0000001058460515_aeb94b88e78974288bab1b4940b50c840"></a><a name="en-us_topic_0000001058460515_aeb94b88e78974288bab1b4940b50c840"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="en-us_topic_0000001058460515_r95c56d5cd62d4b518c3e7a3f158ed7fe"><td class="cellrowborder" valign="top" width="12%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001058460515_a7af41aec9a404f418202d90c61774825"><a name="en-us_topic_0000001058460515_a7af41aec9a404f418202d90c61774825"></a><a name="en-us_topic_0000001058460515_a7af41aec9a404f418202d90c61774825"></a>message</p>
</td>
<td class="cellrowborder" valign="top" width="9%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001058460515_aed6ae868d61349afa8f0e250108f8e47"><a name="en-us_topic_0000001058460515_aed6ae868d61349afa8f0e250108f8e47"></a><a name="en-us_topic_0000001058460515_aed6ae868d61349afa8f0e250108f8e47"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="9%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001058460515_ab72ac8cc02e34da4b717ca144fc521c1"><a name="en-us_topic_0000001058460515_ab72ac8cc02e34da4b717ca144fc521c1"></a><a name="en-us_topic_0000001058460515_ab72ac8cc02e34da4b717ca144fc521c1"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001058460515_ac53e6549d32f413e9c51cd8a53f4650a"><a name="en-us_topic_0000001058460515_ac53e6549d32f413e9c51cd8a53f4650a"></a><a name="en-us_topic_0000001058460515_ac53e6549d32f413e9c51cd8a53f4650a"></a>Text to print</p>
</td>
</tr>
</tbody>
</table>
- Example
```
var versionCode = 1;
console.info('Hello World. The current version code is ' + versionCode);
```
Switch to the **HiLog** window at the bottom of HUAWEI DevEco Studio. Specifically, select the current device and process, set the log level to **Info**, and enter **Hello World** in the search box. Logs that meet the search criteria are displayed, as shown in the following figure.
![](figures/log.png)
> **NOTE:**
>The **console.log\(\)** function prints logs at the debug level.
# Globalization<a name="EN-US_TOPIC_0000001115814852"></a>
## Imported Modules<a name="en-us_topic_0000001103315838_s56d19203690d4782bfc74069abb6bd71"></a>
```
import Intl from '@ohos.intl';
```
## Permissions<a name="en-us_topic_0000001103315838_section11257113618419"></a>
None.
## Class<a name="en-us_topic_0000001103315838_section1956131218111"></a>
## Locale<a name="en-us_topic_0000001103315838_section189341937163212"></a>
Provides APIs for obtaining locale information.
### Attributes<a name="en-us_topic_0000001103315838_section23751576140"></a>
<a name="en-us_topic_0000001103315838_table728861911417"></a>
<table><thead align="left"><tr id="en-us_topic_0000001103315838_row62887198149"><th class="cellrowborder" valign="top" width="15.870000000000001%" id="mcps1.1.6.1.1"><p id="en-us_topic_0000001103315838_p928811911410"><a name="en-us_topic_0000001103315838_p928811911410"></a><a name="en-us_topic_0000001103315838_p928811911410"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="10.86%" id="mcps1.1.6.1.2"><p id="en-us_topic_0000001103315838_p8288191916149"><a name="en-us_topic_0000001103315838_p8288191916149"></a><a name="en-us_topic_0000001103315838_p8288191916149"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9.34%" id="mcps1.1.6.1.3"><p id="en-us_topic_0000001103315838_p14288131911418"><a name="en-us_topic_0000001103315838_p14288131911418"></a><a name="en-us_topic_0000001103315838_p14288131911418"></a>Readable</p>
</th>
<th class="cellrowborder" valign="top" width="11.51%" id="mcps1.1.6.1.4"><p id="en-us_topic_0000001103315838_p1928861921411"><a name="en-us_topic_0000001103315838_p1928861921411"></a><a name="en-us_topic_0000001103315838_p1928861921411"></a>Writable</p>
</th>
<th class="cellrowborder" valign="top" width="52.42%" id="mcps1.1.6.1.5"><p id="en-us_topic_0000001103315838_p728815191149"><a name="en-us_topic_0000001103315838_p728815191149"></a><a name="en-us_topic_0000001103315838_p728815191149"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="en-us_topic_0000001103315838_row528891919142"><td class="cellrowborder" valign="top" width="15.870000000000001%" headers="mcps1.1.6.1.1 "><p id="en-us_topic_0000001103315838_p3288191991414"><a name="en-us_topic_0000001103315838_p3288191991414"></a><a name="en-us_topic_0000001103315838_p3288191991414"></a>language</p>
</td>
<td class="cellrowborder" valign="top" width="10.86%" headers="mcps1.1.6.1.2 "><p id="en-us_topic_0000001103315838_p3288121901418"><a name="en-us_topic_0000001103315838_p3288121901418"></a><a name="en-us_topic_0000001103315838_p3288121901418"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="9.34%" headers="mcps1.1.6.1.3 "><p id="en-us_topic_0000001103315838_p182881319191414"><a name="en-us_topic_0000001103315838_p182881319191414"></a><a name="en-us_topic_0000001103315838_p182881319191414"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="11.51%" headers="mcps1.1.6.1.4 "><p id="en-us_topic_0000001103315838_p1928801914148"><a name="en-us_topic_0000001103315838_p1928801914148"></a><a name="en-us_topic_0000001103315838_p1928801914148"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="52.42%" headers="mcps1.1.6.1.5 "><p id="en-us_topic_0000001103315838_p1428811192144"><a name="en-us_topic_0000001103315838_p1428811192144"></a><a name="en-us_topic_0000001103315838_p1428811192144"></a>Indicates the language of the locale.</p>
</td>
</tr>
<tr id="en-us_topic_0000001103315838_row11288719111417"><td class="cellrowborder" valign="top" width="15.870000000000001%" headers="mcps1.1.6.1.1 "><p id="en-us_topic_0000001103315838_p10288419131415"><a name="en-us_topic_0000001103315838_p10288419131415"></a><a name="en-us_topic_0000001103315838_p10288419131415"></a>script</p>
</td>
<td class="cellrowborder" valign="top" width="10.86%" headers="mcps1.1.6.1.2 "><p id="en-us_topic_0000001103315838_p91710563611"><a name="en-us_topic_0000001103315838_p91710563611"></a><a name="en-us_topic_0000001103315838_p91710563611"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="9.34%" headers="mcps1.1.6.1.3 "><p id="en-us_topic_0000001103315838_p14171165163611"><a name="en-us_topic_0000001103315838_p14171165163611"></a><a name="en-us_topic_0000001103315838_p14171165163611"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="11.51%" headers="mcps1.1.6.1.4 "><p id="en-us_topic_0000001103315838_p1017115543612"><a name="en-us_topic_0000001103315838_p1017115543612"></a><a name="en-us_topic_0000001103315838_p1017115543612"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="52.42%" headers="mcps1.1.6.1.5 "><p id="en-us_topic_0000001103315838_p3171125183610"><a name="en-us_topic_0000001103315838_p3171125183610"></a><a name="en-us_topic_0000001103315838_p3171125183610"></a>Indicates the script of the locale.</p>
</td>
</tr>
<tr id="en-us_topic_0000001103315838_row19687050183612"><td class="cellrowborder" valign="top" width="15.870000000000001%" headers="mcps1.1.6.1.1 "><p id="en-us_topic_0000001103315838_p32281883406"><a name="en-us_topic_0000001103315838_p32281883406"></a><a name="en-us_topic_0000001103315838_p32281883406"></a>region</p>
</td>
<td class="cellrowborder" valign="top" width="10.86%" headers="mcps1.1.6.1.2 "><p id="en-us_topic_0000001103315838_p1522810854016"><a name="en-us_topic_0000001103315838_p1522810854016"></a><a name="en-us_topic_0000001103315838_p1522810854016"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="9.34%" headers="mcps1.1.6.1.3 "><p id="en-us_topic_0000001103315838_p1422858124014"><a name="en-us_topic_0000001103315838_p1422858124014"></a><a name="en-us_topic_0000001103315838_p1422858124014"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="11.51%" headers="mcps1.1.6.1.4 "><p id="en-us_topic_0000001103315838_p1922817874013"><a name="en-us_topic_0000001103315838_p1922817874013"></a><a name="en-us_topic_0000001103315838_p1922817874013"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="52.42%" headers="mcps1.1.6.1.5 "><p id="en-us_topic_0000001103315838_p1722818834016"><a name="en-us_topic_0000001103315838_p1722818834016"></a><a name="en-us_topic_0000001103315838_p1722818834016"></a>Indicates the region of the locale.</p>
</td>
</tr>
<tr id="en-us_topic_0000001103315838_row115871535369"><td class="cellrowborder" valign="top" width="15.870000000000001%" headers="mcps1.1.6.1.1 "><p id="en-us_topic_0000001103315838_p15801188114019"><a name="en-us_topic_0000001103315838_p15801188114019"></a><a name="en-us_topic_0000001103315838_p15801188114019"></a>baseName</p>
</td>
<td class="cellrowborder" valign="top" width="10.86%" headers="mcps1.1.6.1.2 "><p id="en-us_topic_0000001103315838_p108011082401"><a name="en-us_topic_0000001103315838_p108011082401"></a><a name="en-us_topic_0000001103315838_p108011082401"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="9.34%" headers="mcps1.1.6.1.3 "><p id="en-us_topic_0000001103315838_p138011980407"><a name="en-us_topic_0000001103315838_p138011980407"></a><a name="en-us_topic_0000001103315838_p138011980407"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="11.51%" headers="mcps1.1.6.1.4 "><p id="en-us_topic_0000001103315838_p1980128134011"><a name="en-us_topic_0000001103315838_p1980128134011"></a><a name="en-us_topic_0000001103315838_p1980128134011"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="52.42%" headers="mcps1.1.6.1.5 "><p id="en-us_topic_0000001103315838_p1801208144012"><a name="en-us_topic_0000001103315838_p1801208144012"></a><a name="en-us_topic_0000001103315838_p1801208144012"></a>Indicates the basic locale information, which is returned as a substring of a complete locale string.</p>
</td>
</tr>
</tbody>
</table>
### Locale<a name="en-us_topic_0000001103315838_section1410593619146"></a>
A constructor used to create a **Locale** object.
**Parameters**
<a name="en-us_topic_0000001103315838_table114831131512"></a>
<table><thead align="left"><tr id="en-us_topic_0000001103315838_row914851141517"><th class="cellrowborder" valign="top" width="14.82%" id="mcps1.1.5.1.1"><p id="en-us_topic_0000001103315838_p214819113159"><a name="en-us_topic_0000001103315838_p214819113159"></a><a name="en-us_topic_0000001103315838_p214819113159"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="14.729999999999999%" id="mcps1.1.5.1.2"><p id="en-us_topic_0000001103315838_p1214921121519"><a name="en-us_topic_0000001103315838_p1214921121519"></a><a name="en-us_topic_0000001103315838_p1214921121519"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9.16%" id="mcps1.1.5.1.3"><p id="en-us_topic_0000001103315838_p11491711141512"><a name="en-us_topic_0000001103315838_p11491711141512"></a><a name="en-us_topic_0000001103315838_p11491711141512"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="61.29%" id="mcps1.1.5.1.4"><p id="en-us_topic_0000001103315838_p171491011171512"><a name="en-us_topic_0000001103315838_p171491011171512"></a><a name="en-us_topic_0000001103315838_p171491011171512"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="en-us_topic_0000001103315838_row91491211131519"><td class="cellrowborder" valign="top" width="14.82%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001103315838_p45271354164919"><a name="en-us_topic_0000001103315838_p45271354164919"></a><a name="en-us_topic_0000001103315838_p45271354164919"></a>locale</p>
</td>
<td class="cellrowborder" valign="top" width="14.729999999999999%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001103315838_p1252795444917"><a name="en-us_topic_0000001103315838_p1252795444917"></a><a name="en-us_topic_0000001103315838_p1252795444917"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="9.16%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001103315838_p314916118154"><a name="en-us_topic_0000001103315838_p314916118154"></a><a name="en-us_topic_0000001103315838_p314916118154"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001103315838_p814951171516"><a name="en-us_topic_0000001103315838_p814951171516"></a><a name="en-us_topic_0000001103315838_p814951171516"></a>Indicates a character string containing the locale information, including the language and optionally the script and region.</p>
</td>
</tr>
</tbody>
</table>
**Example**
```
var enLatnGB = new Intl.Locale("en-Latn-GB");
var enGB = new Intl.Locale("en-GB");
var en = new Intl.Locale("en");
```
## DateTimeFormat<a name="en-us_topic_0000001103315838_section88061769522"></a>
Provides the API for formatting date strings.
### DateTimeFormat<a name="en-us_topic_0000001103315838_section28081362523"></a>
A constructor used to create a **DateTimeFormat** object.
**Parameters**
<a name="en-us_topic_0000001103315838_table1680806175216"></a>
<table><thead align="left"><tr id="en-us_topic_0000001103315838_row10808868524"><th class="cellrowborder" valign="top" width="14.82%" id="mcps1.1.5.1.1"><p id="en-us_topic_0000001103315838_p108080625215"><a name="en-us_topic_0000001103315838_p108080625215"></a><a name="en-us_topic_0000001103315838_p108080625215"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="14.729999999999999%" id="mcps1.1.5.1.2"><p id="en-us_topic_0000001103315838_p78089645215"><a name="en-us_topic_0000001103315838_p78089645215"></a><a name="en-us_topic_0000001103315838_p78089645215"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9.16%" id="mcps1.1.5.1.3"><p id="en-us_topic_0000001103315838_p17808126175217"><a name="en-us_topic_0000001103315838_p17808126175217"></a><a name="en-us_topic_0000001103315838_p17808126175217"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="61.29%" id="mcps1.1.5.1.4"><p id="en-us_topic_0000001103315838_p15808106185212"><a name="en-us_topic_0000001103315838_p15808106185212"></a><a name="en-us_topic_0000001103315838_p15808106185212"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="en-us_topic_0000001103315838_row19808116205213"><td class="cellrowborder" valign="top" width="14.82%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001103315838_p880815616525"><a name="en-us_topic_0000001103315838_p880815616525"></a><a name="en-us_topic_0000001103315838_p880815616525"></a>locale</p>
</td>
<td class="cellrowborder" valign="top" width="14.729999999999999%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001103315838_p18091655211"><a name="en-us_topic_0000001103315838_p18091655211"></a><a name="en-us_topic_0000001103315838_p18091655211"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="9.16%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001103315838_p19809196105217"><a name="en-us_topic_0000001103315838_p19809196105217"></a><a name="en-us_topic_0000001103315838_p19809196105217"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001103315838_p28095613525"><a name="en-us_topic_0000001103315838_p28095613525"></a><a name="en-us_topic_0000001103315838_p28095613525"></a>Indicates a character string containing the locale information, including the language and optionally the script and region, for the <strong id="en-us_topic_0000001103315838_b06014570014"><a name="en-us_topic_0000001103315838_b06014570014"></a><a name="en-us_topic_0000001103315838_b06014570014"></a>DateTimeFormat</strong> object.</p>
</td>
</tr>
</tbody>
</table>
**Example**
```
var dateFmt = new Intl.DateTimeFormat("en-Latn-GB");
```
### format<a name="en-us_topic_0000001103315838_section917151185514"></a>
Obtains the formatted date strings.
**Parameters**
<a name="en-us_topic_0000001103315838_table61711165519"></a>
<table><thead align="left"><tr id="en-us_topic_0000001103315838_row1176115554"><th class="cellrowborder" valign="top" width="14.82%" id="mcps1.1.5.1.1"><p id="en-us_topic_0000001103315838_p017312552"><a name="en-us_topic_0000001103315838_p017312552"></a><a name="en-us_topic_0000001103315838_p017312552"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="14.729999999999999%" id="mcps1.1.5.1.2"><p id="en-us_topic_0000001103315838_p217112554"><a name="en-us_topic_0000001103315838_p217112554"></a><a name="en-us_topic_0000001103315838_p217112554"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9.16%" id="mcps1.1.5.1.3"><p id="en-us_topic_0000001103315838_p61771165517"><a name="en-us_topic_0000001103315838_p61771165517"></a><a name="en-us_topic_0000001103315838_p61771165517"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="61.29%" id="mcps1.1.5.1.4"><p id="en-us_topic_0000001103315838_p418515559"><a name="en-us_topic_0000001103315838_p418515559"></a><a name="en-us_topic_0000001103315838_p418515559"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="en-us_topic_0000001103315838_row121811118556"><td class="cellrowborder" valign="top" width="14.82%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001103315838_p13181419559"><a name="en-us_topic_0000001103315838_p13181419559"></a><a name="en-us_topic_0000001103315838_p13181419559"></a>date</p>
</td>
<td class="cellrowborder" valign="top" width="14.729999999999999%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001103315838_p918171185515"><a name="en-us_topic_0000001103315838_p918171185515"></a><a name="en-us_topic_0000001103315838_p918171185515"></a>Date</p>
</td>
<td class="cellrowborder" valign="top" width="9.16%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001103315838_p161819114551"><a name="en-us_topic_0000001103315838_p161819114551"></a><a name="en-us_topic_0000001103315838_p161819114551"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001103315838_p718316555"><a name="en-us_topic_0000001103315838_p718316555"></a><a name="en-us_topic_0000001103315838_p718316555"></a>Indicates the <strong id="en-us_topic_0000001103315838_b89491740312"><a name="en-us_topic_0000001103315838_b89491740312"></a><a name="en-us_topic_0000001103315838_b89491740312"></a>Date</strong> object to be formatted.</p>
</td>
</tr>
</tbody>
</table>
**Return Values**
<a name="en-us_topic_0000001103315838_table2187195518"></a>
<table><thead align="left"><tr id="en-us_topic_0000001103315838_row618171115511"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="en-us_topic_0000001103315838_p12186185510"><a name="en-us_topic_0000001103315838_p12186185510"></a><a name="en-us_topic_0000001103315838_p12186185510"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="en-us_topic_0000001103315838_p218171115514"><a name="en-us_topic_0000001103315838_p218171115514"></a><a name="en-us_topic_0000001103315838_p218171115514"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="en-us_topic_0000001103315838_row13181115555"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="en-us_topic_0000001103315838_p3195145512"><a name="en-us_topic_0000001103315838_p3195145512"></a><a name="en-us_topic_0000001103315838_p3195145512"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="en-us_topic_0000001103315838_p3196119551"><a name="en-us_topic_0000001103315838_p3196119551"></a><a name="en-us_topic_0000001103315838_p3196119551"></a>Indicates a date string formatted based on the specified locale.</p>
</td>
</tr>
</tbody>
</table>
**Example**
```
var date = new Date(1995, 11, 25, 3, 14, 0);
var datefmt = new Intl.DateTimeFormat("en-Latn-GB");
var result = datefmt.format(date); // The formatted date string is Dec 25, 1995.
```
# Application Context<a name="EN-US_TOPIC_0000001173324607"></a>
## Module to Import<a name="s1959b1529f574b74861e62008289bb21"></a>
```
import app from '@system.app';
```
## Required Permissions<a name="section11257113618419"></a>
None
## app.getInfo<a name="s0e8ff40704e442bc87a848afa47bdfbb"></a>
getInfo\(\): <[AppResponse](#t3e93239d9b134b80957bcdd4acb05291)\>
Obtains the declared information in the **config.json** file of an application.
- Return values
**Table 1** AppResponse
<a name="t3e93239d9b134b80957bcdd4acb05291"></a>
<table><tbody><tr id="recc81d9f995d44aa87ba9d714b756569"><td class="cellrowborder" valign="top" width="19%"><p id="aa3137ce511d140fba6cc93513a7a91e3"><a name="aa3137ce511d140fba6cc93513a7a91e3"></a><a name="aa3137ce511d140fba6cc93513a7a91e3"></a>Name</p>
</td>
<td class="cellrowborder" valign="top" width="13%"><p id="a6b166163db284e5ca8dc0190b36ae40a"><a name="a6b166163db284e5ca8dc0190b36ae40a"></a><a name="a6b166163db284e5ca8dc0190b36ae40a"></a>Type</p>
</td>
<td class="cellrowborder" valign="top" width="68%"><p id="a4ba8ead9ee7b48298d9a6ed10659f13b"><a name="a4ba8ead9ee7b48298d9a6ed10659f13b"></a><a name="a4ba8ead9ee7b48298d9a6ed10659f13b"></a>Description</p>
</td>
</tr>
<tr id="row2557173813243"><td class="cellrowborder" valign="top" width="19%"><p id="p898462584011"><a name="p898462584011"></a><a name="p898462584011"></a>appID<sup id="sup193948321350"><a name="sup193948321350"></a><a name="sup193948321350"></a>6+</sup></p>
</td>
<td class="cellrowborder" valign="top" width="13%"><p id="p698492564013"><a name="p698492564013"></a><a name="p698492564013"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="68%"><p id="p1998432514020"><a name="p1998432514020"></a><a name="p1998432514020"></a>Bundle name of the application. It uniquely identifies the application.</p>
</td>
</tr>
<tr id="r64430cb15b54497f88ea6330b9a7454c"><td class="cellrowborder" valign="top" width="19%"><p id="a7cccea39636b47cd83188d400eed51e3"><a name="a7cccea39636b47cd83188d400eed51e3"></a><a name="a7cccea39636b47cd83188d400eed51e3"></a>appName</p>
</td>
<td class="cellrowborder" valign="top" width="13%"><p id="a2f72300143c441ef9a3fb5dc2f8e4aac"><a name="a2f72300143c441ef9a3fb5dc2f8e4aac"></a><a name="a2f72300143c441ef9a3fb5dc2f8e4aac"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="68%"><p id="a1c9b8d1829ef489e9e0fd1863190d228"><a name="a1c9b8d1829ef489e9e0fd1863190d228"></a><a name="a1c9b8d1829ef489e9e0fd1863190d228"></a>Application name</p>
</td>
</tr>
<tr id="r4f8f612a65b24ae9b75ae53893aeb3b9"><td class="cellrowborder" valign="top" width="19%"><p id="ae036f88e139e4379abdaf4969f0720ea"><a name="ae036f88e139e4379abdaf4969f0720ea"></a><a name="ae036f88e139e4379abdaf4969f0720ea"></a>versionName</p>
</td>
<td class="cellrowborder" valign="top" width="13%"><p id="a1d379931a20144f0b6d98f5396202cd9"><a name="a1d379931a20144f0b6d98f5396202cd9"></a><a name="a1d379931a20144f0b6d98f5396202cd9"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="68%"><p id="a70c91c442f7c41439a90ceb9041252e8"><a name="a70c91c442f7c41439a90ceb9041252e8"></a><a name="a70c91c442f7c41439a90ceb9041252e8"></a>Application version name</p>
</td>
</tr>
<tr id="r89cf0afd5f444bd1b66ace0c31a25cda"><td class="cellrowborder" valign="top" width="19%"><p id="a3a86c086e40e475b8fb26cf43fe9a8d6"><a name="a3a86c086e40e475b8fb26cf43fe9a8d6"></a><a name="a3a86c086e40e475b8fb26cf43fe9a8d6"></a>versionCode</p>
</td>
<td class="cellrowborder" valign="top" width="13%"><p id="abcfd352ff3d84552938de0e2daf0703e"><a name="abcfd352ff3d84552938de0e2daf0703e"></a><a name="abcfd352ff3d84552938de0e2daf0703e"></a>number</p>
</td>
<td class="cellrowborder" valign="top" width="68%"><p id="af943e2ec7622407387d25d9331a01245"><a name="af943e2ec7622407387d25d9331a01245"></a><a name="af943e2ec7622407387d25d9331a01245"></a>Application version</p>
</td>
</tr>
</tbody>
</table>
- Example
```
export default {
getInfo(){
var info = app.getInfo();
console.log(JSON.stringify(info));
}
}
```
## app.terminate<a name="section974325124119"></a>
terminate\(\): void
Destroys the current ability.
- Example
```
export default {
terminate(){
app.terminate();
}}
```
# Application Configuration<a name="EN-US_TOPIC_0000001173324675"></a>
## Module to Import<a name="section15536249155915"></a>
```
import configuration from '@system.configuration';
```
## Required Permissions<a name="section8152081004"></a>
None
## configuration.getLocale<a name="section8389829903"></a>
getLocale\(\): <[LocaleResponse](#table1544853546)\>
Obtains the current locale of the application, which is the same as the system locale.
- Return values
**Table 1** LocaleResponse
<a name="table1544853546"></a>
<table><thead align="left"><tr id="row1670755549"><th class="cellrowborder" valign="top" width="17.77177717771777%" id="mcps1.2.4.1.1"><p id="p57013505413"><a name="p57013505413"></a><a name="p57013505413"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="12.5012501250125%" id="mcps1.2.4.1.2"><p id="p9706511540"><a name="p9706511540"></a><a name="p9706511540"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="69.72697269726973%" id="mcps1.2.4.1.3"><p id="p16701957548"><a name="p16701957548"></a><a name="p16701957548"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row15709513545"><td class="cellrowborder" valign="top" width="17.77177717771777%" headers="mcps1.2.4.1.1 "><p id="p1370154548"><a name="p1370154548"></a><a name="p1370154548"></a>language</p>
</td>
<td class="cellrowborder" valign="top" width="12.5012501250125%" headers="mcps1.2.4.1.2 "><p id="p19701653545"><a name="p19701653545"></a><a name="p19701653545"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="69.72697269726973%" headers="mcps1.2.4.1.3 "><p id="p37010510548"><a name="p37010510548"></a><a name="p37010510548"></a>Current language of the application, for example, <strong id="b1260120418488"><a name="b1260120418488"></a><a name="b1260120418488"></a>zh</strong>.</p>
</td>
</tr>
<tr id="row970165135413"><td class="cellrowborder" valign="top" width="17.77177717771777%" headers="mcps1.2.4.1.1 "><p id="p97055105414"><a name="p97055105414"></a><a name="p97055105414"></a>countryOrRegion</p>
</td>
<td class="cellrowborder" valign="top" width="12.5012501250125%" headers="mcps1.2.4.1.2 "><p id="p1770175115413"><a name="p1770175115413"></a><a name="p1770175115413"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="69.72697269726973%" headers="mcps1.2.4.1.3 "><p id="p77015518544"><a name="p77015518544"></a><a name="p77015518544"></a>Country or region, for example, <strong id="b6258316114819"><a name="b6258316114819"></a><a name="b6258316114819"></a>CN</strong>.</p>
</td>
</tr>
<tr id="row6332114185611"><td class="cellrowborder" valign="top" width="17.77177717771777%" headers="mcps1.2.4.1.1 "><p id="p53321542567"><a name="p53321542567"></a><a name="p53321542567"></a>dir</p>
</td>
<td class="cellrowborder" valign="top" width="12.5012501250125%" headers="mcps1.2.4.1.2 "><p id="p1433216410564"><a name="p1433216410564"></a><a name="p1433216410564"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="69.72697269726973%" headers="mcps1.2.4.1.3 "><p id="p33321417565"><a name="p33321417565"></a><a name="p33321417565"></a>Text layout direction. Available values are as follows:</p>
<a name="ul1861816241119"></a><a name="ul1861816241119"></a><ul id="ul1861816241119"><li><strong id="b16720155216481"><a name="b16720155216481"></a><a name="b16720155216481"></a>ltr</strong>: The text direction is from left to right.</li><li><strong id="b1910563194919"><a name="b1910563194919"></a><a name="b1910563194919"></a>rtl</strong>: The text direction is from right to left.</li></ul>
</td>
</tr>
<tr id="row165137101137"><td class="cellrowborder" valign="top" width="17.77177717771777%" headers="mcps1.2.4.1.1 "><p id="p1351311101333"><a name="p1351311101333"></a><a name="p1351311101333"></a>unicodeSetting<sup id="sup1646171814502"><a name="sup1646171814502"></a><a name="sup1646171814502"></a>5+</sup></p>
</td>
<td class="cellrowborder" valign="top" width="12.5012501250125%" headers="mcps1.2.4.1.2 "><p id="p1513121019313"><a name="p1513121019313"></a><a name="p1513121019313"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="69.72697269726973%" headers="mcps1.2.4.1.3 "><p id="p97106183311"><a name="p97106183311"></a><a name="p97106183311"></a>Unicode key set determined by the locale.</p>
<p id="p213145115319"><a name="p213145115319"></a><a name="p213145115319"></a>For example, <strong id="b14471162633518"><a name="b14471162633518"></a><a name="b14471162633518"></a>{"nu":"arab"}</strong> indicates that the current locale uses Arabic numerals.</p>
<p id="p849701364"><a name="p849701364"></a><a name="p849701364"></a>If the current locale does not have a specific key set, an empty set is returned.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
export default {
getLocale() {
const localeInfo = configuration.getLocale();
console.info(localeInfo.language);
}
}
```
# Console Logs<a name="EN-US_TOPIC_0000001127284842"></a>
## Module to Import<a name="s56d19203690d4782bfc74069abb6bd71"></a>
No module is required.
## Required Permissions<a name="section11257113618419"></a>
None
## console.debug<a name="s298a3cf59a3b470dbb0742706102ced7"></a>
debug\(message: string\): void
Prints debug logs.
- Parameters
<a name="t87748b0ba4e648079d53f9deccf4bfb2"></a>
<table><thead align="left"><tr id="rc5033ad045c14c2e806d59041aab002c"><th class="cellrowborder" valign="top" width="12%" id="mcps1.1.5.1.1"><p id="acf783ab6043e4ee1a7bb73b73a091e0b"><a name="acf783ab6043e4ee1a7bb73b73a091e0b"></a><a name="acf783ab6043e4ee1a7bb73b73a091e0b"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="9%" id="mcps1.1.5.1.2"><p id="a6736505551534b819d5a6376065a25f6"><a name="a6736505551534b819d5a6376065a25f6"></a><a name="a6736505551534b819d5a6376065a25f6"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9%" id="mcps1.1.5.1.3"><p id="ac15c2a3de0e046af917cf09b48b3b46d"><a name="ac15c2a3de0e046af917cf09b48b3b46d"></a><a name="ac15c2a3de0e046af917cf09b48b3b46d"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="70%" id="mcps1.1.5.1.4"><p id="aeb94b88e78974288bab1b4940b50c840"><a name="aeb94b88e78974288bab1b4940b50c840"></a><a name="aeb94b88e78974288bab1b4940b50c840"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="r95c56d5cd62d4b518c3e7a3f158ed7fe"><td class="cellrowborder" valign="top" width="12%" headers="mcps1.1.5.1.1 "><p id="a7af41aec9a404f418202d90c61774825"><a name="a7af41aec9a404f418202d90c61774825"></a><a name="a7af41aec9a404f418202d90c61774825"></a>message</p>
</td>
<td class="cellrowborder" valign="top" width="9%" headers="mcps1.1.5.1.2 "><p id="aed6ae868d61349afa8f0e250108f8e47"><a name="aed6ae868d61349afa8f0e250108f8e47"></a><a name="aed6ae868d61349afa8f0e250108f8e47"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="9%" headers="mcps1.1.5.1.3 "><p id="ab72ac8cc02e34da4b717ca144fc521c1"><a name="ab72ac8cc02e34da4b717ca144fc521c1"></a><a name="ab72ac8cc02e34da4b717ca144fc521c1"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.5.1.4 "><p id="ac53e6549d32f413e9c51cd8a53f4650a"><a name="ac53e6549d32f413e9c51cd8a53f4650a"></a><a name="ac53e6549d32f413e9c51cd8a53f4650a"></a>Text to print.</p>
</td>
</tr>
</tbody>
</table>
## console.log<a name="section146351482051"></a>
log\(message: string\): void
Prints debug logs.
- Parameter
<a name="table1852992312613"></a>
<table><thead align="left"><tr id="row953019231468"><th class="cellrowborder" valign="top" width="12%" id="mcps1.1.5.1.1"><p id="p353020231164"><a name="p353020231164"></a><a name="p353020231164"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="9%" id="mcps1.1.5.1.2"><p id="p15301423361"><a name="p15301423361"></a><a name="p15301423361"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9%" id="mcps1.1.5.1.3"><p id="p853022316618"><a name="p853022316618"></a><a name="p853022316618"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="70%" id="mcps1.1.5.1.4"><p id="p1953072310614"><a name="p1953072310614"></a><a name="p1953072310614"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row6530823560"><td class="cellrowborder" valign="top" width="12%" headers="mcps1.1.5.1.1 "><p id="p135301231364"><a name="p135301231364"></a><a name="p135301231364"></a>message</p>
</td>
<td class="cellrowborder" valign="top" width="9%" headers="mcps1.1.5.1.2 "><p id="p15530523265"><a name="p15530523265"></a><a name="p15530523265"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="9%" headers="mcps1.1.5.1.3 "><p id="p165301323567"><a name="p165301323567"></a><a name="p165301323567"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.5.1.4 "><p id="p853019231265"><a name="p853019231265"></a><a name="p853019231265"></a>Text to print.</p>
</td>
</tr>
</tbody>
</table>
## console.info<a name="section93434457711"></a>
info\(message: string\): void
Prints info-level logs.
- Parameters
<a name="table611782915816"></a>
<table><thead align="left"><tr id="row1211714291989"><th class="cellrowborder" valign="top" width="12%" id="mcps1.1.5.1.1"><p id="p41174291587"><a name="p41174291587"></a><a name="p41174291587"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="9%" id="mcps1.1.5.1.2"><p id="p711715295817"><a name="p711715295817"></a><a name="p711715295817"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9%" id="mcps1.1.5.1.3"><p id="p101171729289"><a name="p101171729289"></a><a name="p101171729289"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="70%" id="mcps1.1.5.1.4"><p id="p17117162911815"><a name="p17117162911815"></a><a name="p17117162911815"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row411762913814"><td class="cellrowborder" valign="top" width="12%" headers="mcps1.1.5.1.1 "><p id="p111178291284"><a name="p111178291284"></a><a name="p111178291284"></a>message</p>
</td>
<td class="cellrowborder" valign="top" width="9%" headers="mcps1.1.5.1.2 "><p id="p91181929284"><a name="p91181929284"></a><a name="p91181929284"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="9%" headers="mcps1.1.5.1.3 "><p id="p12118152919810"><a name="p12118152919810"></a><a name="p12118152919810"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.5.1.4 "><p id="p18118112910811"><a name="p18118112910811"></a><a name="p18118112910811"></a>Text to print.</p>
</td>
</tr>
</tbody>
</table>
## console.warn<a name="section1363520541678"></a>
warn\(message: string\): void
Prints warn-level logs.
- Parameters
<a name="table2396103815819"></a>
<table><thead align="left"><tr id="row13396183810811"><th class="cellrowborder" valign="top" width="12%" id="mcps1.1.5.1.1"><p id="p3396153815820"><a name="p3396153815820"></a><a name="p3396153815820"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="9%" id="mcps1.1.5.1.2"><p id="p13964389819"><a name="p13964389819"></a><a name="p13964389819"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9%" id="mcps1.1.5.1.3"><p id="p53961138987"><a name="p53961138987"></a><a name="p53961138987"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="70%" id="mcps1.1.5.1.4"><p id="p0396238787"><a name="p0396238787"></a><a name="p0396238787"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row9396163811811"><td class="cellrowborder" valign="top" width="12%" headers="mcps1.1.5.1.1 "><p id="p33966385817"><a name="p33966385817"></a><a name="p33966385817"></a>message</p>
</td>
<td class="cellrowborder" valign="top" width="9%" headers="mcps1.1.5.1.2 "><p id="p639610381280"><a name="p639610381280"></a><a name="p639610381280"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="9%" headers="mcps1.1.5.1.3 "><p id="p0396183816816"><a name="p0396183816816"></a><a name="p0396183816816"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.5.1.4 "><p id="p039613818815"><a name="p039613818815"></a><a name="p039613818815"></a>Text to print.</p>
</td>
</tr>
</tbody>
</table>
## console.error<a name="section326012551578"></a>
error\(message: string\): void
Prints error-level logs.
- Parameters
<a name="table79914568813"></a>
<table><thead align="left"><tr id="row899656288"><th class="cellrowborder" valign="top" width="12%" id="mcps1.1.5.1.1"><p id="p39911567816"><a name="p39911567816"></a><a name="p39911567816"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="9%" id="mcps1.1.5.1.2"><p id="p099156388"><a name="p099156388"></a><a name="p099156388"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9%" id="mcps1.1.5.1.3"><p id="p3992564819"><a name="p3992564819"></a><a name="p3992564819"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="70%" id="mcps1.1.5.1.4"><p id="p89920561088"><a name="p89920561088"></a><a name="p89920561088"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row799956389"><td class="cellrowborder" valign="top" width="12%" headers="mcps1.1.5.1.1 "><p id="p699105614811"><a name="p699105614811"></a><a name="p699105614811"></a>message</p>
</td>
<td class="cellrowborder" valign="top" width="9%" headers="mcps1.1.5.1.2 "><p id="p99925618816"><a name="p99925618816"></a><a name="p99925618816"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="9%" headers="mcps1.1.5.1.3 "><p id="p189916561082"><a name="p189916561082"></a><a name="p189916561082"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.5.1.4 "><p id="p799195610812"><a name="p799195610812"></a><a name="p799195610812"></a>Text to print.</p>
</td>
</tr>
</tbody>
</table>
## Example<a name="section738673813104"></a>
```
export default {
clickConsole(){
var versionCode = 1;
console.info('Hello World. The current version code is ' + versionCode);
console.log(`versionCode: ${versionCode}`);
// The following is supported since API version 6.
console.log('versionCode:%d.', versionCode);
}
}
```
Switch to the **HiLog** window at the bottom of HUAWEI DevEco Studio. Specifically, select the current device and process, set the log level to **Info**, and enter **Hello World** in the search box. Logs that meet the search criteria are displayed, as shown in the following figure.
![](figures/log.png)
# Timer<a name="EN-US_TOPIC_0000001173324687"></a>
>![](../../public_sys-resources/icon-note.gif) **NOTE:**
>The initial APIs of this module are supported since API version 4. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Module to Import<a name="section7480141454919"></a>
None
## Required Permissions<a name="section11257113618419"></a>
None
## setTimeout<a name="section691616559215"></a>
setTimeout\(handler\[,delay\[, ...args\]\]\): number
Sets a timer for the system to call a function after the timer goes off.
- Parameters
<a name="t80f094cffa594e7e842eccce3bf1eb19"></a>
<table><thead align="left"><tr id="rd6c76d49b85e4aea9496fd457b189a2a"><th class="cellrowborder" valign="top" width="14.180000000000001%" id="mcps1.1.5.1.1"><p id="aca3ed031fef246189779018bbcab4df3"><a name="aca3ed031fef246189779018bbcab4df3"></a><a name="aca3ed031fef246189779018bbcab4df3"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="16.61%" id="mcps1.1.5.1.2"><p id="a89f9e11cc75c4aa9b0b31af966020f61"><a name="a89f9e11cc75c4aa9b0b31af966020f61"></a><a name="a89f9e11cc75c4aa9b0b31af966020f61"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="6.3%" id="mcps1.1.5.1.3"><p id="a411664c3845840d4b2a6845105703f3b"><a name="a411664c3845840d4b2a6845105703f3b"></a><a name="a411664c3845840d4b2a6845105703f3b"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="62.91%" id="mcps1.1.5.1.4"><p id="ac962681702ac49e09c77a1270af9ecb2"><a name="ac962681702ac49e09c77a1270af9ecb2"></a><a name="ac962681702ac49e09c77a1270af9ecb2"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="r9d3ffb29e7e74ff4b18e0a3e3ad04925"><td class="cellrowborder" valign="top" width="14.180000000000001%" headers="mcps1.1.5.1.1 "><p id="p1411112320620"><a name="p1411112320620"></a><a name="p1411112320620"></a>handler</p>
</td>
<td class="cellrowborder" valign="top" width="16.61%" headers="mcps1.1.5.1.2 "><p id="p11016237618"><a name="p11016237618"></a><a name="p11016237618"></a>Function</p>
</td>
<td class="cellrowborder" valign="top" width="6.3%" headers="mcps1.1.5.1.3 "><p id="p1892231068"><a name="p1892231068"></a><a name="p1892231068"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="62.91%" headers="mcps1.1.5.1.4 "><p id="p788516491307"><a name="p788516491307"></a><a name="p788516491307"></a>Function to be called after the timer goes off.</p>
</td>
</tr>
<tr id="r57344f1bd4304d548bf54ba81dbe8fa5"><td class="cellrowborder" valign="top" width="14.180000000000001%" headers="mcps1.1.5.1.1 "><p id="p13718237614"><a name="p13718237614"></a><a name="p13718237614"></a>delay</p>
</td>
<td class="cellrowborder" valign="top" width="16.61%" headers="mcps1.1.5.1.2 "><p id="p261239618"><a name="p261239618"></a><a name="p261239618"></a>number</p>
</td>
<td class="cellrowborder" valign="top" width="6.3%" headers="mcps1.1.5.1.3 "><p id="p17516231062"><a name="p17516231062"></a><a name="p17516231062"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="62.91%" headers="mcps1.1.5.1.4 "><p id="p1943234615"><a name="p1943234615"></a><a name="p1943234615"></a>Number of milliseconds delayed before the execution. If this parameter is left empty, the default value <strong id="b1264512254010"><a name="b1264512254010"></a><a name="b1264512254010"></a>0</strong> is used, which means that the execution starts immediately or as soon as possible.</p>
</td>
</tr>
<tr id="r41a55619ed484b7092dfc843ebd4fba1"><td class="cellrowborder" valign="top" width="14.180000000000001%" headers="mcps1.1.5.1.1 "><p id="p103182316615"><a name="p103182316615"></a><a name="p103182316615"></a>...args</p>
</td>
<td class="cellrowborder" valign="top" width="16.61%" headers="mcps1.1.5.1.2 "><p id="p1321231162"><a name="p1321231162"></a><a name="p1321231162"></a>Array&lt;any&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="6.3%" headers="mcps1.1.5.1.3 "><p id="p11111231363"><a name="p11111231363"></a><a name="p11111231363"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="62.91%" headers="mcps1.1.5.1.4 "><p id="p139991022863"><a name="p139991022863"></a><a name="p139991022863"></a>Additional parameter to pass to the handler after the timer goes off.</p>
</td>
</tr>
</tbody>
</table>
- Return Value
<a name="table1430416594311"></a>
<table><thead align="left"><tr id="row230485973113"><th class="cellrowborder" valign="top" width="12.18%" id="mcps1.1.3.1.1"><p id="p430405913312"><a name="p430405913312"></a><a name="p430405913312"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="87.82%" id="mcps1.1.3.1.2"><p id="p830413599312"><a name="p830413599312"></a><a name="p830413599312"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row130435914317"><td class="cellrowborder" valign="top" width="12.18%" headers="mcps1.1.3.1.1 "><p id="p4305759143119"><a name="p4305759143119"></a><a name="p4305759143119"></a>number</p>
</td>
<td class="cellrowborder" valign="top" width="87.82%" headers="mcps1.1.3.1.2 "><p id="p130555923110"><a name="p130555923110"></a><a name="p130555923110"></a>Timer ID.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
export default {
setTimeOut() {
var timeoutID = setTimeout(function() {
console.log('delay 1s');
}, 1000);
}
}
```
## clearTimeout<a name="section591824471012"></a>
clearTimeout\(timeoutID: number\): void
Cancels the timer created via **setTimeout\(\)**.
- Parameter
<a name="table242593951313"></a>
<table><thead align="left"><tr id="row1642533921320"><th class="cellrowborder" valign="top" width="14.180000000000001%" id="mcps1.1.5.1.1"><p id="p15425539131316"><a name="p15425539131316"></a><a name="p15425539131316"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="9.700000000000001%" id="mcps1.1.5.1.2"><p id="p442518395136"><a name="p442518395136"></a><a name="p442518395136"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="6.18%" id="mcps1.1.5.1.3"><p id="p6425153915136"><a name="p6425153915136"></a><a name="p6425153915136"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="69.94%" id="mcps1.1.5.1.4"><p id="p9425193910134"><a name="p9425193910134"></a><a name="p9425193910134"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row1442613913132"><td class="cellrowborder" valign="top" width="14.180000000000001%" headers="mcps1.1.5.1.1 "><p id="p16426133931310"><a name="p16426133931310"></a><a name="p16426133931310"></a>timeoutID</p>
</td>
<td class="cellrowborder" valign="top" width="9.700000000000001%" headers="mcps1.1.5.1.2 "><p id="p16426639151316"><a name="p16426639151316"></a><a name="p16426639151316"></a>number</p>
</td>
<td class="cellrowborder" valign="top" width="6.18%" headers="mcps1.1.5.1.3 "><p id="p1426739141312"><a name="p1426739141312"></a><a name="p1426739141312"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="69.94%" headers="mcps1.1.5.1.4 "><p id="p6426183941319"><a name="p6426183941319"></a><a name="p6426183941319"></a>ID of the timer to cancel, which is returned by <strong id="b5804644564"><a name="b5804644564"></a><a name="b5804644564"></a>setTimeout()</strong></p>
</td>
</tr>
</tbody>
</table>
- Example
```
export default {
clearTimeOut() {
var timeoutID = setTimeout(function() {
console.log('do after 1s delay.');
}, 1000);
clearTimeout(timeoutID);
}
}
```
## setInterval<a name="section3644185910144"></a>
setInterval\(handler\[, delay\[, ...args\]\]\): number
Sets a repeating timer for the system to repeatedly call a function at a fixed interval.
- Parameters
<a name="table2064413592143"></a>
<table><thead align="left"><tr id="row16441591142"><th class="cellrowborder" valign="top" width="14.180000000000001%" id="mcps1.1.5.1.1"><p id="p0644195915145"><a name="p0644195915145"></a><a name="p0644195915145"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="16.61%" id="mcps1.1.5.1.2"><p id="p1264413594142"><a name="p1264413594142"></a><a name="p1264413594142"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="6.3%" id="mcps1.1.5.1.3"><p id="p86449591147"><a name="p86449591147"></a><a name="p86449591147"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="62.91%" id="mcps1.1.5.1.4"><p id="p16644185991417"><a name="p16644185991417"></a><a name="p16644185991417"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row264495931412"><td class="cellrowborder" valign="top" width="14.180000000000001%" headers="mcps1.1.5.1.1 "><p id="p8644659161413"><a name="p8644659161413"></a><a name="p8644659161413"></a>handler</p>
</td>
<td class="cellrowborder" valign="top" width="16.61%" headers="mcps1.1.5.1.2 "><p id="p7645259181410"><a name="p7645259181410"></a><a name="p7645259181410"></a>Function</p>
</td>
<td class="cellrowborder" valign="top" width="6.3%" headers="mcps1.1.5.1.3 "><p id="p12645259111415"><a name="p12645259111415"></a><a name="p12645259111415"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="62.91%" headers="mcps1.1.5.1.4 "><p id="p4645155931418"><a name="p4645155931418"></a><a name="p4645155931418"></a>Function to be called repeatedly</p>
</td>
</tr>
<tr id="row264575911146"><td class="cellrowborder" valign="top" width="14.180000000000001%" headers="mcps1.1.5.1.1 "><p id="p17645159201410"><a name="p17645159201410"></a><a name="p17645159201410"></a>delay</p>
</td>
<td class="cellrowborder" valign="top" width="16.61%" headers="mcps1.1.5.1.2 "><p id="p3645175951416"><a name="p3645175951416"></a><a name="p3645175951416"></a>number</p>
</td>
<td class="cellrowborder" valign="top" width="6.3%" headers="mcps1.1.5.1.3 "><p id="p1645185981412"><a name="p1645185981412"></a><a name="p1645185981412"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="62.91%" headers="mcps1.1.5.1.4 "><p id="p13645559141415"><a name="p13645559141415"></a><a name="p13645559141415"></a>Number of milliseconds delayed before the execution</p>
</td>
</tr>
<tr id="row96452594148"><td class="cellrowborder" valign="top" width="14.180000000000001%" headers="mcps1.1.5.1.1 "><p id="p4645105911412"><a name="p4645105911412"></a><a name="p4645105911412"></a>...args</p>
</td>
<td class="cellrowborder" valign="top" width="16.61%" headers="mcps1.1.5.1.2 "><p id="p1564595951413"><a name="p1564595951413"></a><a name="p1564595951413"></a>Array&lt;any&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="6.3%" headers="mcps1.1.5.1.3 "><p id="p12645175971411"><a name="p12645175971411"></a><a name="p12645175971411"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="62.91%" headers="mcps1.1.5.1.4 "><p id="p12645105991413"><a name="p12645105991413"></a><a name="p12645105991413"></a>Additional parameter to pass to the handler after the timer goes off</p>
</td>
</tr>
</tbody>
</table>
- Return Value
<a name="table1947971515356"></a>
<table><thead align="left"><tr id="row247915156359"><th class="cellrowborder" valign="top" width="12.18%" id="mcps1.1.3.1.1"><p id="p54794159353"><a name="p54794159353"></a><a name="p54794159353"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="87.82%" id="mcps1.1.3.1.2"><p id="p14798156359"><a name="p14798156359"></a><a name="p14798156359"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row747919155356"><td class="cellrowborder" valign="top" width="12.18%" headers="mcps1.1.3.1.1 "><p id="p6479101518359"><a name="p6479101518359"></a><a name="p6479101518359"></a>number</p>
</td>
<td class="cellrowborder" valign="top" width="87.82%" headers="mcps1.1.3.1.2 "><p id="p10479151518353"><a name="p10479151518353"></a><a name="p10479151518353"></a>ID of the repeated timer.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
export default {
setInterval() {
var intervalID = setInterval(function() {
console.log('do very 1s.');
}, 1000);
}
}
```
## clearInterval<a name="section16451595149"></a>
clearInterval\(intervalID: number\): void
Cancels the repeating timer set via **setInterval\(\)**.
- Parameter
<a name="table86463597147"></a>
<table><thead align="left"><tr id="row146462597148"><th class="cellrowborder" valign="top" width="14.180000000000001%" id="mcps1.1.5.1.1"><p id="p176461759111416"><a name="p176461759111416"></a><a name="p176461759111416"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="9.700000000000001%" id="mcps1.1.5.1.2"><p id="p8646195918141"><a name="p8646195918141"></a><a name="p8646195918141"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="6.18%" id="mcps1.1.5.1.3"><p id="p19646165981415"><a name="p19646165981415"></a><a name="p19646165981415"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="69.94%" id="mcps1.1.5.1.4"><p id="p8646185961419"><a name="p8646185961419"></a><a name="p8646185961419"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row12646125914143"><td class="cellrowborder" valign="top" width="14.180000000000001%" headers="mcps1.1.5.1.1 "><p id="p1964675951413"><a name="p1964675951413"></a><a name="p1964675951413"></a>intervalID</p>
</td>
<td class="cellrowborder" valign="top" width="9.700000000000001%" headers="mcps1.1.5.1.2 "><p id="p1864625921419"><a name="p1864625921419"></a><a name="p1864625921419"></a>number</p>
</td>
<td class="cellrowborder" valign="top" width="6.18%" headers="mcps1.1.5.1.3 "><p id="p3646145921419"><a name="p3646145921419"></a><a name="p3646145921419"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="69.94%" headers="mcps1.1.5.1.4 "><p id="p7646459141416"><a name="p7646459141416"></a><a name="p7646459141416"></a>ID of the repeating timer to cancel, which is returned by <strong id="b1855918269134"><a name="b1855918269134"></a><a name="b1855918269134"></a>setInterval()</strong>.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
export default {
clearInterval() {
var intervalID = setInterval(function() {
console.log('do very 1s.');
}, 1000);
clearInterval(intervalID);
}
}
```
此差异已折叠。
此差异已折叠。
...@@ -2,9 +2,7 @@ ...@@ -2,9 +2,7 @@
>**Note:** >**Note:**
> >
>- The APIs of this module are supported since API version 6. >The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
>- APIs marked with <sup>7+</sup> are supported since API version 7.
## Modules to Import ## Modules to Import
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
>**Note:** >**Note:**
> >
>- The APIs of this module are supported since API version 6. >The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>- APIs marked with <sup>7+</sup> are supported since API version 7.
## Modules to Import ## Modules to Import
......
此差异已折叠。
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
>**Note:** >**Note:**
> >
>- The APIs of this module are supported since API version 6. >The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>- APIs marked with <sup>7+</sup> are supported since API version 7.
## Modules to Import ## Modules to Import
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册