flagUrl関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
The address of a flag's SVG file, for an <img src> or a CSS url(): on the jsDelivr CDN by default, or in
a folder of your own. The file is the same SVG as the module's string.
インポート
import { flagUrl } from "@johnmorrisdotca/hata";
定義
function flagUrl(code: string, options?: FlagUrlOptions): string | null
引数
| 名前 | 型 | 説明 |
|---|---|---|
code | string | A flag's code, in any case (as |
options (省略可) | FlagUrlOptions |
|
戻り値
string | null
The address (…/jp-13.svg), or null when the code has no flag here.
例
import { flagUrl } from "@johnmorrisdotca/hata";
console.log(flagUrl("JP-13")); // "https://cdn.jsdelivr.net/npm/@johnmorrisdotca/hata@1/dist/svg/jp-13.svg"
console.log(flagUrl("us-tx", { base: "/flags/" })); // "/flags/us-tx.svg"
console.log(flagUrl("XX")); // nullhttps://cdn.jsdelivr.net/npm/@johnmorrisdotca/hata@1/dist/svg/jp-13.svg
/flags/us-tx.svg
null出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。