js-components-basic-qrcode.md 7.9 KB
Newer Older
Z
zengyawen 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
# qrcode<a name="EN-US_TOPIC_0000001127284846"></a>

The  **<qrcode\>**  component is used to generate and display a QR code.

>![](../../public_sys-resources/icon-note.gif) **NOTE:** 
>This component is supported since API version 5.

## Permission List<a name="section11257113618419"></a>

None

## Child Component<a name="section352513155564"></a>

Not supported

## Attribute<a name="section5347151165210"></a>

In addition to the attributes in  [Universal Attributes](js-components-common-attributes.md), the following attributes are supported.

<a name="table20633101642315"></a>
<table><thead align="left"><tr id="row663331618238"><th class="cellrowborder" valign="top" width="23.119999999999997%" id="mcps1.1.6.1.1"><p id="aa872998ac2d84843a3c5161889afffef"><a name="aa872998ac2d84843a3c5161889afffef"></a><a name="aa872998ac2d84843a3c5161889afffef"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="23.119999999999997%" id="mcps1.1.6.1.2"><p id="ab2111648ee0e4f6d881be8954e7acaab"><a name="ab2111648ee0e4f6d881be8954e7acaab"></a><a name="ab2111648ee0e4f6d881be8954e7acaab"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="10.48%" id="mcps1.1.6.1.3"><p id="ab377d1c90900478ea4ecab51e9a058af"><a name="ab377d1c90900478ea4ecab51e9a058af"></a><a name="ab377d1c90900478ea4ecab51e9a058af"></a>Default Value</p>
</th>
<th class="cellrowborder" valign="top" width="7.5200000000000005%" id="mcps1.1.6.1.4"><p id="p824610360217"><a name="p824610360217"></a><a name="p824610360217"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="35.76%" id="mcps1.1.6.1.5"><p id="a1d574a0044ed42ec8a2603bc82734232"><a name="a1d574a0044ed42ec8a2603bc82734232"></a><a name="a1d574a0044ed42ec8a2603bc82734232"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row126185265127"><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p id="p024862891210"><a name="p024862891210"></a><a name="p024862891210"></a>value</p>
</td>
<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p id="p12248142813120"><a name="p12248142813120"></a><a name="p12248142813120"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p id="p124815283126"><a name="p124815283126"></a><a name="p124815283126"></a>-</p>
</td>
<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.6.1.4 "><p id="p1248102811127"><a name="p1248102811127"></a><a name="p1248102811127"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="35.76%" headers="mcps1.1.6.1.5 "><p id="p3248828131212"><a name="p3248828131212"></a><a name="p3248828131212"></a>Content used to generate the QR code</p>
</td>
</tr>
<tr id="row15957823161214"><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p id="p1248142816121"><a name="p1248142816121"></a><a name="p1248142816121"></a>type</p>
</td>
<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p id="p4248528121210"><a name="p4248528121210"></a><a name="p4248528121210"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p id="p924814288126"><a name="p924814288126"></a><a name="p924814288126"></a>rect</p>
</td>
<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.6.1.4 "><p id="p162481828101210"><a name="p162481828101210"></a><a name="p162481828101210"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="35.76%" headers="mcps1.1.6.1.5 "><p id="p2248182810126"><a name="p2248182810126"></a><a name="p2248182810126"></a>QR code type. Available values are as follows:</p>
<a name="ul19772143474918"></a><a name="ul19772143474918"></a><ul id="ul19772143474918"><li><strong id="b1932091716183"><a name="b1932091716183"></a><a name="b1932091716183"></a>rect</strong>: rectangular QR code</li><li><strong id="b13684142218183"><a name="b13684142218183"></a><a name="b13684142218183"></a>circle</strong>: round QR code</li></ul>
</td>
</tr>
</tbody>
</table>

## Style<a name="section439317598552"></a>

In addition to the styles in  [Universal Styles](js-components-common-styles.md), the following styles are supported.

<a name="table417918285463"></a>
<table><thead align="left"><tr id="row318012811464"><th class="cellrowborder" valign="top" width="23.11768823117688%" id="mcps1.1.6.1.1"><p id="p1918014281467"><a name="p1918014281467"></a><a name="p1918014281467"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="20.477952204779523%" id="mcps1.1.6.1.2"><p id="p14180172824614"><a name="p14180172824614"></a><a name="p14180172824614"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="8.869113088691131%" id="mcps1.1.6.1.3"><p id="p618052814461"><a name="p618052814461"></a><a name="p618052814461"></a>Default Value</p>
</th>
<th class="cellrowborder" valign="top" width="7.519248075192481%" id="mcps1.1.6.1.4"><p id="p518016281467"><a name="p518016281467"></a><a name="p518016281467"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="40.01599840015999%" id="mcps1.1.6.1.5"><p id="p10180152834613"><a name="p10180152834613"></a><a name="p10180152834613"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row718014289468"><td class="cellrowborder" valign="top" width="23.11768823117688%" headers="mcps1.1.6.1.1 "><p id="p141800287465"><a name="p141800287465"></a><a name="p141800287465"></a>color</p>
</td>
<td class="cellrowborder" valign="top" width="20.477952204779523%" headers="mcps1.1.6.1.2 "><p id="p20180182824617"><a name="p20180182824617"></a><a name="p20180182824617"></a>&lt;color&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="8.869113088691131%" headers="mcps1.1.6.1.3 "><p id="p14180162804617"><a name="p14180162804617"></a><a name="p14180162804617"></a>#000000</p>
</td>
<td class="cellrowborder" valign="top" width="7.519248075192481%" headers="mcps1.1.6.1.4 "><p id="p17180028144615"><a name="p17180028144615"></a><a name="p17180028144615"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="40.01599840015999%" headers="mcps1.1.6.1.5 "><p id="p31809283467"><a name="p31809283467"></a><a name="p31809283467"></a>QR code color</p>
</td>
</tr>
<tr id="row1918072894618"><td class="cellrowborder" valign="top" width="23.11768823117688%" headers="mcps1.1.6.1.1 "><p id="p1418012818468"><a name="p1418012818468"></a><a name="p1418012818468"></a>background-color</p>
</td>
<td class="cellrowborder" valign="top" width="20.477952204779523%" headers="mcps1.1.6.1.2 "><p id="p181807285461"><a name="p181807285461"></a><a name="p181807285461"></a>&lt;color&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="8.869113088691131%" headers="mcps1.1.6.1.3 "><p id="p5180162818469"><a name="p5180162818469"></a><a name="p5180162818469"></a>#ffffff</p>
</td>
<td class="cellrowborder" valign="top" width="7.519248075192481%" headers="mcps1.1.6.1.4 "><p id="p118022824620"><a name="p118022824620"></a><a name="p118022824620"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="40.01599840015999%" headers="mcps1.1.6.1.5 "><p id="p11180182834614"><a name="p11180182834614"></a><a name="p11180182834614"></a>QR code background color</p>
</td>
</tr>
</tbody>
</table>

>![](../../public_sys-resources/icon-note.gif) **NOTE:** 
>-   If the values of  **width**  and  **height**  are different, the smaller value is used as the length of the QR code. The generated QR code is center displayed.
>-   If either  **width**  or  **height**  is set, the value is used as the length of the QR code. If neither of them is set, the default length is 200 px.

## Event<a name="section1948820711216"></a>

Events in  [Universal Events](js-components-common-events.md)  are supported.

## Method<a name="section2279124532420"></a>

Methods in  [Universal Methods](js-components-common-methods.md)  are supported.

## Example<a name="section81001951259"></a>

```
<qrcode value="https://huawei.com"></qrcode>
```