Skip to content

Commit a0496e2

Browse files
async.md sezione componenti
1 parent 43a728b commit a0496e2

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed

src/guide/components/async.md

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
# Async Components {#async-components}
1+
# Componenti asincroni {#async-components}
22

3-
## Basic Usage {#basic-usage}
3+
## Utilizzo base {#basic-usage}
44

5-
In large applications, we may need to divide the app into smaller chunks and only load a component from the server when it's needed. To make that possible, Vue has a [`defineAsyncComponent`](/api/general#defineasynccomponent) function:
5+
Nelle grandi applicazioni, potrebbe essere necessario dividere l'applicazione in chunk più piccoli e caricare un componente dal server solo quando è necessario. Per rendere ciò possibile, Vue ha una funzione [`defineAsyncComponent`](/api/general#defineasynccomponent):
66

77
```js
88
import { defineAsyncComponent } from 'vue'
99

1010
const AsyncComp = defineAsyncComponent(() => {
1111
return new Promise((resolve, reject) => {
12-
// ...load component from server
13-
resolve(/* loaded component */)
12+
// ...carica il componente dal server
13+
resolve(/* componente montato */)
1414
})
1515
})
16-
// ... use `AsyncComp` like a normal component
16+
// ... utilizzo normale del componente
1717
```
1818

19-
As you can see, `defineAsyncComponent` accepts a loader function that returns a Promise. The Promise's `resolve` callback should be called when you have retrieved your component definition from the server. You can also call `reject(reason)` to indicate the load has failed.
19+
Come si può notare, `defineAsyncComponent` accetta una funzione loader che restituisce una Promise. La funzione `resolve` della Promise dovrebbe essere chiamata quando hai recuperato la definizione del componente dal server. Puoi anche chiamare `reject(reason)` per indicare che il caricamento è fallito.
2020

21-
[ES module dynamic import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import) also returns a Promise, so most of the time we will use it in combination with `defineAsyncComponent`. Bundlers like Vite and webpack also support the syntax (and will use it as bundle split points), so we can use it to import Vue SFCs:
21+
[ES module dynamic import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import) restituisce anche una Promise, quindi nella maggior parte dei casi lo useremo in combinazione con `defineAsyncComponent`. I bundler come Vite e webpack supportano anche questa sintassi (e la utilizzeranno per dividere i bundle), quindi possiamo usarla per importare i file SFC di Vue.
2222

2323
```js
2424
import { defineAsyncComponent } from 'vue'
@@ -28,9 +28,9 @@ const AsyncComp = defineAsyncComponent(() =>
2828
)
2929
```
3030

31-
The resulting `AsyncComp` is a wrapper component that only calls the loader function when it is actually rendered on the page. In addition, it will pass along any props and slots to the inner component, so you can use the async wrapper to seamlessly replace the original component while achieving lazy loading.
31+
Il componente risultante `AsyncComp` è un componente wrapper che chiama la funzione di caricamento solo quando viene effettivamente reso nella pagina. Inoltre, passerà tutte le props e gli slot al componente interno, consentendoti di utilizzare il wrapper asincrono per sostituire senza problemi il componente originale ottenendo il lazy loading.
3232

33-
As with normal components, async components can be [registered globally](/guide/components/registration#global-registration) using `app.component()`:
33+
Come con i componenti normali, i componenti asincroni possono essere [registrati globalmente](/guide/components/registration#global-registration) utilizzando `app.component()`:
3434

3535
```js
3636
app.component('MyComponent', defineAsyncComponent(() =>
@@ -40,7 +40,7 @@ app.component('MyComponent', defineAsyncComponent(() =>
4040

4141
<div class="options-api">
4242

43-
You can also use `defineAsyncComponent` when [registering a component locally](/guide/components/registration#local-registration):
43+
Puoi anche utilizzare `defineAsyncComponent` quando [registri un componente localmente](/guide/components/registration#local-registration):
4444

4545
```vue
4646
<script>
@@ -64,7 +64,7 @@ export default {
6464

6565
<div class="composition-api">
6666

67-
They can also be defined directly inside their parent component:
67+
Possono anche essere definiti direttamente all'interno del componente genitore:
6868

6969
```vue
7070
<script setup>
@@ -82,32 +82,31 @@ const AdminPage = defineAsyncComponent(() =>
8282

8383
</div>
8484

85-
## Loading and Error States {#loading-and-error-states}
85+
## Stati di caricamento e di errore {#stati-di-caricamento-e-di-errore}
8686

87-
Asynchronous operations inevitably involve loading and error states - `defineAsyncComponent()` supports handling these states via advanced options:
87+
Le operazioni asincrone implicano inevitabilmente stati di caricamento e di errore. `defineAsyncComponent()` supporta la gestione di questi stati tramite opzioni avanzate:
8888

8989
```js
9090
const AsyncComp = defineAsyncComponent({
91-
// the loader function
91+
// la funzione loader
9292
loader: () => import('./Foo.vue'),
9393

94-
// A component to use while the async component is loading
94+
// Componente utilizzato durante il caricamento dell'async component
9595
loadingComponent: LoadingComponent,
96-
// Delay before showing the loading component. Default: 200ms.
96+
// Ritardo prima di mostrare il componente di caricamento. Predefinito: 200ms.
9797
delay: 200,
9898

99-
// A component to use if the load fails
99+
// Componente utilizzato se il caricamento fallisce
100100
errorComponent: ErrorComponent,
101-
// The error component will be displayed if a timeout is
102-
// provided and exceeded. Default: Infinity.
101+
// Il componente di errore verrà mostrato se viene fornito un timeout ed è superato. Predefinito: Infinity.
103102
timeout: 3000
104103
})
105104
```
106105

107-
If a loading component is provided, it will be displayed first while the inner component is being loaded. There is a default 200ms delay before the loading component is shown - this is because on fast networks, an instant loading state may get replaced too fast and end up looking like a flicker.
106+
Se viene fornito un componente di caricamento, verrà mostrato prima mentre l'inner component viene caricato. C'è un ritardo predefinito di 200 ms prima che il componente di caricamento venga mostrato - questo perché su reti veloci, uno stato di caricamento istantaneo potrebbe essere sostituito troppo velocemente e sembrare un lampeggio.
108107

109-
If an error component is provided, it will be displayed when the Promise returned by the loader function is rejected. You can also specify a timeout to show the error component when the request is taking too long.
108+
Se viene fornito un componente di errore, verrà mostrato quando la Promise restituita dalla funzione di caricamento viene rifiutata. È anche possibile specificare un timeout per mostrare il componente di errore quando la richiesta sta richiedendo troppo tempo.
110109

111110
## Using with Suspense {#using-with-suspense}
112111

113-
Async components can be used with the `<Suspense>` built-in component. The interaction between `<Suspense>` and async components is documented in the [dedicated chapter for `<Suspense>`](/guide/built-ins/suspense).
112+
I componenti asincroni possono essere utilizzati con il componente integrato `<Suspense>`. L'interazione tra `<Suspense>` e i componenti asincroni è documentata nel [capitolo dedicato a `<Suspense>`](/guide/built-ins/suspense).

src/guide/typescript/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Vue stesso è scritto in TypeScript e offre un supporto TypeScript di prima clas
1010

1111
## Creare un applicazione {#project-setup}
1212

13-
[`create-vue`](https://github.com/vuejs/create-vue), il tool ufficiale, offre la possibilità di creare un progetto [Vite](https://vitejs.dev/) TypeScript-ready.
13+
[`create-vue`](https://github.com/vuejs/create-vue), il tool ufficiale, offre la possibilità di creare un progetto [Vite](https://vitejs.dev/) con TypeScript già incluso.
1414

1515
### Overview {#overview}
1616

0 commit comments

Comments
 (0)