Notice: file_put_contents(): Write of 12701 bytes failed with errno=28 No space left on device in /var/www/tgoop/post.php on line 50

Warning: file_put_contents(): Only 4096 of 16797 bytes written, possibly out of free disk space in /var/www/tgoop/post.php on line 50
Web Devs@fullStackDevs P.626
FULLSTACKDEVS Telegram 626
#Vuejs
#ComponentLifeCycleHook

#سوال
🔰چگونه Hook های Child Component را در کامپوننت Parent صدا بزنیم؟

🔸در ویو جی اس به صورت معمولی برای اجرای کدی در زمان صدا زده شدن Hook های کامپوننت Child از روش زیر استفاده میکنیم.

🔹روش نرمال انجام این هدف، emit کردن یک Custom Event در کامپوننت child و Bind کردن یک متد به این Custom Event در کامپوننت Parent است، و بدین تصورت میتوانیم کد مد نظر خودمان را در هنگام صدا شده شدن Hook مربوطه کامپوننت Child اجرا کنیم.
🔹به عوان مثال می خواهیم قطعه کد X در زمانی که Hook mounted کامپوننت Child صدا زده شد، اجرا شود.

`<!-- Child -->
<script>
export default {
mounted () {
this.$emit('onMounted')
}
}
</script><!-- Parent -->
<template>
<Child @
onMounted="handleOnMounted" />
</template>`

❇️ اما راه حل ساده و جایگزین دیگری نیز وجود دارد برای این کار کافیست به این شکل عمل کنید :
`<!-- Parent -->
<template>
<Child
@hook:mounted="handleOnMounted" />
</template>`


🔸در نتیجه handleOnMounted در زمان call شدن هوک مشخص شده اجرا میشود.

@fullStackDevs



tgoop.com/fullStackDevs/626
Create:
Last Update:

#Vuejs
#ComponentLifeCycleHook

#سوال
🔰چگونه Hook های Child Component را در کامپوننت Parent صدا بزنیم؟

🔸در ویو جی اس به صورت معمولی برای اجرای کدی در زمان صدا زده شدن Hook های کامپوننت Child از روش زیر استفاده میکنیم.

🔹روش نرمال انجام این هدف، emit کردن یک Custom Event در کامپوننت child و Bind کردن یک متد به این Custom Event در کامپوننت Parent است، و بدین تصورت میتوانیم کد مد نظر خودمان را در هنگام صدا شده شدن Hook مربوطه کامپوننت Child اجرا کنیم.
🔹به عوان مثال می خواهیم قطعه کد X در زمانی که Hook mounted کامپوننت Child صدا زده شد، اجرا شود.

`<!-- Child -->
<script>
export default {
mounted () {
this.$emit('onMounted')
}
}
</script><!-- Parent -->
<template>
<Child @
onMounted="handleOnMounted" />
</template>`

❇️ اما راه حل ساده و جایگزین دیگری نیز وجود دارد برای این کار کافیست به این شکل عمل کنید :
`<!-- Parent -->
<template>
<Child
@hook:mounted="handleOnMounted" />
</template>`


🔸در نتیجه handleOnMounted در زمان call شدن هوک مشخص شده اجرا میشود.

@fullStackDevs

BY Web Devs


Share with your friend now:
tgoop.com/fullStackDevs/626

View MORE
Open in Telegram


Telegram News

Date: |

Members can post their voice notes of themselves screaming. Interestingly, the group doesn’t allow to post anything else which might lead to an instant ban. As of now, there are more than 330 members in the group. The Channel name and bio must be no more than 255 characters long Telegram has announced a number of measures aiming to tackle the spread of disinformation through its platform in Brazil. These features are part of an agreement between the platform and the country's authorities ahead of the elections in October. Telegram channels fall into two types: You can invite up to 200 people from your contacts to join your channel as the next step. Select the users you want to add and click “Invite.” You can skip this step altogether.
from us


Telegram Web Devs
FROM American