Skip to content

Commit 9b55653

Browse files
progressi pagina props
1 parent 1e031ab commit 9b55653

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

src/guide/components/props.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# Props {#props}
22

3-
> This page assumes you've already read the [Components Basics](/guide/essentials/component-basics). Read that first if you are new to components.
3+
> Si assume che tu abbia già letto le [Basi dei componenti](/guide/essentials/component-basics). Leggi prima quello se sei nuovo al concetto di componente.
44
55
<div class="options-api">
66
<VueSchoolLink href="https://vueschool.io/lessons/vue-3-reusable-components-with-props" title="Free Vue.js Props Lesson"/>
77
</div>
88

9-
## Props Declaration {#props-declaration}
9+
## Dichiarazione delle Props {#props-declaration}
1010

11-
Vue components require explicit props declaration so that Vue knows what external props passed to the component should be treated as fallthrough attributes (which will be discussed in [its dedicated section](/guide/components/attrs)).
11+
I componenti di Vue richiedono una dichiarazione esplicita delle props affinché Vue sappia come trattare le props esterne passate al componente come attributi passanti (che verranno discusse nella [sezione dedicata](/guide/components/attrs)).
1212

1313
<div class="composition-api">
1414

15-
In SFCs using `<script setup>`, props can be declared using the `defineProps()` macro:
15+
Nei SFC utilizzando `<script setup>`, le props possono essere dichiarate utilizzando la macro `defineProps()`:
1616

1717
```vue
1818
<script setup>
@@ -22,39 +22,39 @@ console.log(props.foo)
2222
</script>
2323
```
2424

25-
In non-`<script setup>` components, props are declared using the [`props`](/api/options-state#props) option:
25+
Nei componenti non-`<script setup>`, le props vengono dichiarate utilizzando la sezione [`props`](/api/options-state#props):
2626

2727
```js
2828
export default {
2929
props: ['foo'],
3030
setup(props) {
31-
// setup() receives props as the first argument.
31+
// setup() prende props come primo parametro
3232
console.log(props.foo)
3333
}
3434
}
3535
```
3636

37-
Notice the argument passed to `defineProps()` is the same as the value provided to the `props` options: the same props options API is shared between the two declaration styles.
37+
Nota che l'argomento passato a defineProps() è lo stesso valore fornito all'opzione props: la stessa API di opzioni per le props è condivisa tra i due stili di dichiarazione..
3838

3939
</div>
4040

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

43-
Props are declared using the [`props`](/api/options-state#props) option:
43+
Le props vengono dichiarate nella sezione [`props`](/api/options-state#props):
4444

4545
```js
4646
export default {
4747
props: ['foo'],
4848
created() {
49-
// props are exposed on `this`
49+
// puoi riferirti alle props con `this`
5050
console.log(this.foo)
5151
}
5252
}
5353
```
5454

5555
</div>
5656

57-
In addition to declaring props using an array of strings, we can also use the object syntax:
57+
Oltre a dichiarare le props utilizzando un array di stringhe, possiamo anche utilizzare la sintassi dell'oggetto:
5858

5959
<div class="options-api">
6060

@@ -79,7 +79,7 @@ defineProps({
7979
```
8080

8181
```js
82-
// in non-<script setup>
82+
// non-<script setup>
8383
export default {
8484
props: {
8585
title: String,
@@ -90,19 +90,19 @@ export default {
9090

9191
</div>
9292

93-
For each property in the object declaration syntax, the key is the name of the prop, while the value should be the constructor function of the expected type.
93+
Per ogni proprietà nella sintassi di dichiarazione dell'oggetto, la chiave rappresenta il nome della prop, mentre il valore dovrebbe essere la funzione costruttrice del tipo previsto.
9494

95-
This not only documents your component, but will also warn other developers using your component in the browser console if they pass the wrong type. We will discuss more details about [prop validation](#prop-validation) further down this page.
95+
Questo non solo documenta il componente, ma avvertirà anche gli altri sviluppatori che utilizzano il componente nella console del browser se passano un tipo errato. Discuteremo ulteriori dettagli sulla [validazione delle props](#prop-validation) più avanti in questa pagina.
9696

9797
<div class="options-api">
9898

99-
See also: [Typing Component Props](/guide/typescript/options-api#typing-component-props) <sup class="vt-badge ts" />
99+
Guarda anche: [Typing Component Props](/guide/typescript/options-api#typing-component-props) <sup class="vt-badge ts" />
100100

101101
</div>
102102

103103
<div class="composition-api">
104104

105-
If you are using TypeScript with `<script setup>`, it's also possible to declare props using pure type annotations:
105+
Se stai usando TypeScript con `<script setup>`, è anche possibile dichiarare le props utilizzando solo annotazioni di tipo:
106106

107107
```vue
108108
<script setup lang="ts">
@@ -113,15 +113,15 @@ defineProps<{
113113
</script>
114114
```
115115

116-
More details: [Typing Component Props](/guide/typescript/composition-api#typing-component-props) <sup class="vt-badge ts" />
116+
Più dettagli: [Typing Component Props](/guide/typescript/composition-api#typing-component-props) <sup class="vt-badge ts" />
117117

118118
</div>
119119

120-
## Prop Passing Details {#prop-passing-details}
120+
## Dettagli sul passaggio delle Props {#prop-passing-details}
121121

122-
### Prop Name Casing {#prop-name-casing}
122+
### Casing dei nomi delle Props {#prop-name-casing}
123123

124-
We declare long prop names using camelCase because this avoids having to use quotes when using them as property keys, and allows us to reference them directly in template expressions because they are valid JavaScript identifiers:
124+
Dichiarare i nomi delle props lunghi utilizzando camelCase ci permette di evitare l'uso di virgolette quando li utilizziamo come chiavi di proprietà e ci consente di farvi riferimento direttamente nelle espressioni del template, poiché sono identificatori JavaScript validi:
125125

126126
<div class="composition-api">
127127

@@ -148,48 +148,48 @@ export default {
148148
<span>{{ greetingMessage }}</span>
149149
```
150150

151-
Technically, you can also use camelCase when passing props to a child component (except in [DOM templates](/guide/essentials/component-basics#dom-template-parsing-caveats)). However, the convention is using kebab-case in all cases to align with HTML attributes:
151+
Tecnicamente, puoi anche utilizzare camelCase quando passi props a un componente figlio (ad eccezione dei [template DOM](/guide/essentials/component-basics#dom-template-parsing-caveats)). Tuttavia, la convenzione è utilizzare kebab-case in tutti i casi per allinearsi agli attributi HTML:
152152

153153
```vue-html
154154
<MyComponent greeting-message="hello" />
155155
```
156156

157-
We use [PascalCase for component tags](/guide/components/registration#component-name-casing) when possible because it improves template readability by differentiating Vue components from native elements. However, there isn't as much practical benefit in using camelCase when passing props, so we choose to follow each language's conventions.
157+
Utilizziamo [PascalCase per i tag dei componenti](/guide/components/registration#component-name-casing) quando possibile poiché migliora la leggibilità del template differenziando i componenti Vue dagli elementi nativi. Tuttavia, non ci sono molti vantaggi pratici nell'utilizzare camelCase quando si passano props, quindi scegliamo di seguire le convenzioni di ciascun linguaggio.
158158

159-
### Static vs. Dynamic Props {#static-vs-dynamic-props}
159+
### Props Statiche vs. Dinamiche {#static-vs-dynamic-props}
160160

161-
So far, you've seen props passed as static values, like in:
161+
Finora, hai visto le props passate come valori statici, come in:
162162

163163
```vue-html
164164
<BlogPost title="My journey with Vue" />
165165
```
166166

167-
You've also seen props assigned dynamically with `v-bind` or its `:` shortcut, such as in:
167+
Hai anche visto le props assegnate dinamicamente con v-bind o il suo abbreviato :, come ad esempio in:
168168

169169
```vue-html
170-
<!-- Dynamically assign the value of a variable -->
170+
<!-- Assegna dinamicamente il valore di una variabile -->
171171
<BlogPost :title="post.title" />
172172
173-
<!-- Dynamically assign the value of a complex expression -->
173+
<!-- Assegna dinamicamente il valore di una espressione complessa -->
174174
<BlogPost :title="post.title + ' by ' + post.author.name" />
175175
```
176176

177-
### Passing Different Value Types {#passing-different-value-types}
177+
### Passaggio di diversi tipi di valori {#passing-different-value-types}
178178

179-
In the two examples above, we happen to pass string values, but _any_ type of value can be passed to a prop.
179+
Negli esempi sopra, casualmente abbiamo passato valori di tipo stringa, ma _qualsiasi_ tipo di valore può essere passato a una prop.
180180

181-
#### Number {#number}
181+
#### Numero {#number}
182182

183183
```vue-html
184-
<!-- Even though `42` is static, we need v-bind to tell Vue that -->
185-
<!-- this is a JavaScript expression rather than a string. -->
184+
<!-- Anche se `42` è statico, abbiamo bisogno di v-bind per indicare a Vue che -->
185+
<!-- questa è un'espressione JavaScript piuttosto che una stringa. -->
186186
<BlogPost :likes="42" />
187187
188-
<!-- Dynamically assign to the value of a variable. -->
188+
<!-- Assegna dinamicamente il valore di una variabile -->
189189
<BlogPost :likes="post.likes" />
190190
```
191191

192-
#### Boolean {#boolean}
192+
#### Booleani {#boolean}
193193

194194
```vue-html
195195
<!-- Including the prop with no value will imply `true`. -->

0 commit comments

Comments
 (0)