passaggio delle proprietà come props
per passare dati al component
| | |
| | | <template> |
| | | <section> |
| | | <header> |
| | | <h1>My friends</h1> |
| | | </header> |
| | | |
| | | |
| | | <ul> |
| | | <friend-contact></friend-contact> |
| | | <friend-contact></friend-contact> |
| | | </ul> |
| | | </section> |
| | | <section> |
| | | <header> |
| | | <h1>My friends</h1> |
| | | </header> |
| | | <ul> |
| | | <friend-contact |
| | | name="Manuel Lorenz" |
| | | phone-number="123" |
| | | email-address="cicio@ciccio.it" |
| | | ></friend-contact> |
| | | <friend-contact |
| | | name="Jeany Torpedo" |
| | | phone-number="123123" |
| | | email-address="torpedo@ciccio.it" |
| | | ></friend-contact> |
| | | </ul> |
| | | </section> |
| | | </template> |
| | | |
| | | <script> |
| | | export default { |
| | | data() { |
| | | return { |
| | | friends: [ |
| | | { |
| | | id: "manuel", |
| | | name: "Manuel Lorenz", |
| | | phone: "01234 5678 991", |
| | | email: "manuel@localhost.com", |
| | | }, |
| | | { |
| | | id: "julie", |
| | | name: "Julie Jones", |
| | | phone: "09876 543 221", |
| | | email: "julie@localhost.com", |
| | | }, |
| | | ], |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | friends: [ |
| | | { |
| | | id: "manuel", |
| | | name: "Manuel Lorenz", |
| | | phone: "01234 5678 991", |
| | | email: "manuel@localhost.com", |
| | | }, |
| | | { |
| | | id: "julie", |
| | | name: "Julie Jones", |
| | | phone: "09876 543 221", |
| | | email: "julie@localhost.com", |
| | | }, |
| | | ], |
| | | } |
| | | }, |
| | | }; |
| | | </script> |
| | | |
| | | <style> |
| | | @import url('https://fonts.googleapis.com/css2?family=Jost&display=swap'); |
| | | @import url('https://fonts.googleapis.com/css2?family=Jost&display=swap'); |
| | | |
| | | * { |
| | | box-sizing: border-box; |
| | |
| | | border-color: #ec3169; |
| | | box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.26); |
| | | } |
| | | |
| | | </style> |
| | |
| | | <template> |
| | | <li> |
| | | <h2>{{ friend.name }}</h2> |
| | | <h2>{{ name }}</h2> |
| | | <button @click="toggleDetails"> |
| | | {{ detailsAreVisible ? 'Hide' : 'Show' }} Details |
| | | </button> |
| | | <ul v-if="detailsAreVisible"> |
| | | <li><strong>Phone:</strong> {{ friend.phone }}</li> |
| | | <li><strong>Email:</strong> {{ friend.email }}</li> |
| | | <li><strong>Phone:</strong> {{ phoneNumber }}</li> |
| | | <li><strong>Email:</strong> {{ emailAddress }}</li> |
| | | </ul> |
| | | </li> |
| | | </template> |
| | | |
| | | <script> |
| | | export default { |
| | | props: [ |
| | | 'name', |
| | | 'phoneNumber', |
| | | 'emailAddress', |
| | | ], |
| | | data() { |
| | | return { |
| | | detailsAreVisible: false, |