kopia lustrzana https://github.com/shoelace-style/shoelace
Minor fixes
rodzic
4e2cf2e9de
commit
a8deeb0659
docs/components
src/components/format-number
|
@ -4,7 +4,7 @@
|
|||
|
||||
Formats a number using the specified locale and options.
|
||||
|
||||
Localization is handled by the browser's built-in [Intl: NumberFormat API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat). As such, there's no need to load language packs or omit those you don't plan on using.
|
||||
Localization is handled by the browser's built-in [Intl: NumberFormat API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat) so there's no need to load bulky language packs.
|
||||
|
||||
```html preview
|
||||
<div class="format-number-overview">
|
||||
|
@ -43,7 +43,7 @@ Use the `locale` attribute to set the number formatting locale.
|
|||
```html preview
|
||||
English: <sl-format-number value="2000" locale="en" minimum-fraction-digits="2"></sl-format-number><br>
|
||||
German: <sl-format-number value="2000" locale="de" minimum-fraction-digits="2"></sl-format-number><br>
|
||||
Russian: <sl-format-number value="2000" locale="ru" minimum-fraction-digits="2"></sl-format-number><br>
|
||||
Russian: <sl-format-number value="2000" locale="ru" minimum-fraction-digits="2"></sl-format-number>
|
||||
```
|
||||
|
||||
### Currency
|
||||
|
|
|
@ -10,7 +10,7 @@ import { Component, Prop } from '@stencil/core';
|
|||
shadow: true
|
||||
})
|
||||
export class FormatBytes {
|
||||
/** The number to format in bytes. */
|
||||
/** The number to format. */
|
||||
@Prop() value = 0;
|
||||
|
||||
/** The locale to use when formatting the number. */
|
||||
|
@ -44,9 +44,7 @@ export class FormatBytes {
|
|||
@Prop() maximumSignificantDigits: number;
|
||||
|
||||
render() {
|
||||
const number = Number(this.value);
|
||||
|
||||
if (isNaN(number)) {
|
||||
if (isNaN(this.value)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -60,6 +58,6 @@ export class FormatBytes {
|
|||
maximumFractionDigits: this.maximumFractionDigits,
|
||||
minimumSignificantDigits: this.minimumSignificantDigits,
|
||||
maximumSignificantDigits: this.maximumSignificantDigits
|
||||
}).format(number);
|
||||
}).format(this.value);
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue