**问题现象**

自定义界面扫码扫到码值后，如何连续扫码？

**解决措施**

customScan.[rescan](https://developer.huawei.com/consumer/cn/doc/harmonyos-references/scan-customscan-api#section19244173211169)可以重新触发一次扫码，必须在customScan.[start](https://developer.huawei.com/consumer/cn/doc/harmonyos-references/scan-customscan-api#section747366165913)(viewControl, callback)方法Callback接口回调中有效，Promise方式无效。

示例：

收起

自动换行

深色代码主题

复制

```
1. import { AsyncCallback, BusinessError } from '@kit.BasicServicesKit';
2. import { hilog } from '@kit.PerformanceAnalysisKit';
3. import { customScan, scanBarcode } from '@kit.ScanKit';

5. @Entry
6. @Component
7. struct Index {
8. private callback: AsyncCallback<Array<scanBarcode.ScanResult>> =
9. (error: BusinessError, result: Array<scanBarcode.ScanResult>) => {
10. if (error) {
11. hilog.error(0x0001, '[Scan Sample]',
12. `Failed to get ScanResult by callback. Code: ${error.code}, message: ${error.message}`);
13. return;
14. }
15. hilog.info(0x0001, '[Scan Sample]',
16. `Succeeded in getting ScanResult by callback, result is ${JSON.stringify(result)}`);
17. try {
18. // 重新触发扫码：不需要重启相机并重新触发一次扫码，可以在start接口的Callback异步回调中，调用rescan接口。
19. customScan.rescan();
20. } catch (error) {
21. hilog.error(0x0001, '[Scan Sample]', `Failed to rescan. Code: ${error.code}, message: ${error.message}`);
22. }
23. }

25. build() {
26. }
27. }
```