pull/282/head
Cory LaViska 2020-11-10 09:33:16 -05:00
rodzic 4e2cf2e9de
commit a8deeb0659
2 zmienionych plików z 5 dodań i 7 usunięć
docs/components
src/components/format-number

Wyświetl plik

@ -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

Wyświetl plik

@ -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);
}
}