endCapture() (従来)

スキャンセッションを終了し、モバイル OS のスキャンインターフェースを閉じて、リソースを削除するには、この関数を使用します。

LWC のスキャンコードで最新の scan() API および dismiss() API を使用して、開発環境を簡素化することをお勧めします。従来の beginCapture() API、resumeCapture() API、endCapture() API は引き続き使用できますが、将来のリリースで廃止される予定です。

Note

構文 

1import { getBarcodeScanner } from 'lightning/mobileCapabilities';
2endCapture(): void

パラメータ 

なし。

戻り値 

なし。

使用方法 

1myScanner
2  .beginCapture(scanningOptions)
3  .then((result) => {
4    console.log(result);
5    this.scannedBarcode = result.value;
6  })
7  .catch((error) => {
8    console.error(error);
9  })
10  .finally(() => {
11    // Handle final cleanup
12    myScanner.endCapture();
13  });

endCapture() をコールしたら、既存または新規 BarcodeScanner インスタンスで beginCapture() をコールして、新しいスキャンセッションを開始できます。

関連トピック

The Japanese Summer '24 guide is now live

日本語の Summer '24 ガイドが公開されました! 「Component Reference (コンポーネントリファレンス)」は、以前と同様にコンポーネントライブラリにあります。