Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

script-setup #186

Merged

Conversation

hosseinghs
Copy link
Contributor

No description provided.

Copy link

vercel bot commented Apr 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-fa ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 16, 2024 7:58am

Copy link
Member

@mostafa-nematpour mostafa-nematpour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

سلام وقت بخیر لطفا موارد رو برسی کنید

Comment on lines 7 to 8
- کارایی و پرفرمونس بهتر در زمان اجرا (تمپلیت در همان اسکوپ به یک render function تبدیل می شود، بدون پروکس میانی)
- پرفرمونس بهتر IDE برای تشخیص type-inference (برای تشخیص نوع داده ها کار کمتری انجام می شود)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- کارایی و پرفرمونس بهتر در زمان اجرا (تمپلیت در همان اسکوپ به یک render function تبدیل می شود، بدون پروکس میانی)
- پرفرمونس بهتر IDE برای تشخیص type-inference (برای تشخیص نوع داده ها کار کمتری انجام می شود)
- کارایی و پرفورمنس بهتر در زمان اجرا (تمپلیت در همان اسکوپ به یک render function تبدیل می شود، بدون پروکسی میانی)
- پرفورمنس بهتر IDE برای تشخیص type-inference (برای تشخیص نوع داده ها کار کمتری انجام می شود)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

سلام، ممنون از ریویو، اصلاحات انجام شد، ممنون میشم چک کنید دوباره


```vue
<script setup>
console.log('hello script setup')
</script>
```

The code inside is compiled as the content of the component's `setup()` function. This means that unlike normal `<script>`, which only executes once when the component is first imported, code inside `<script setup>` will **execute every time an instance of the component is created**.
کد داخل اسکریپت تبدیل می شود به محتوای داخل تابع `()setup` کامپوننت. به این معنی که برخلاف تگ معمولی اسکریپت `<script>`، که فقط یک بار زمانی که کامپوننت برای بار اول ایمپرت شده است اجرا می شود، کد داخل `<script setup>` **هر با که یک instance از کامپوننت ساخته شود، اجرا می شود**.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
کد داخل اسکریپت تبدیل می شود به محتوای داخل تابع `()setup` کامپوننت. به این معنی که برخلاف تگ معمولی اسکریپت `<script>`، که فقط یک بار زمانی که کامپوننت برای بار اول ایمپرت شده است اجرا می شود، کد داخل `<script setup>` **هر با که یک instance از کامپوننت ساخته شود، اجرا می شود**.
کد داخل اسکریپت تبدیل میشود به محتوای داخل تابع `()setup` کامپوننت. به این معنی که برخلاف تگ معمولی اسکریپت `<script>`، که فقط یک بار زمانی که کامپوننت برای بار اول ایمپورت شده است اجرا میشود، کد داخل `<script setup>` **هر با که یک instance از کامپوننت ساخته شود، اجرا میشود**.


### Top-level bindings are exposed to template {#top-level-bindings-are-exposed-to-template}

When using `<script setup>`, any top-level bindings (including variables, function declarations, and imports) declared inside `<script setup>` are directly usable in the template:
زمانی که از `<script setup>` استفاده میکنید، هر top-level bindings (شامل متغیرها، توابع و ایمپرت ها) که داخل `<script setup>` قرار دارند، به صورت مستقیم در تمپلیت قابل استفاده هستند:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
زمانی که از `<script setup>` استفاده میکنید، هر top-level bindings (شامل متغیرها، توابع و ایمپرت ها) که داخل `<script setup>` قرار دارند، به صورت مستقیم در تمپلیت قابل استفاده هستند:
زمانی که از `<script setup>` استفاده می‌کنید، هر top-level bindings (شامل متغیرها، توابع و ایمپورت‌ها) که داخل `<script setup>` قرار دارند، به صورت مستقیم در تمپلیت قابل استفاده هستند:

@@ -39,7 +39,7 @@ function log() {
</template>
```

Imports are exposed in the same fashion. This means you can directly use an imported helper function in template expressions without having to expose it via the `methods` option:
ایپمرت ها هم به همین صورت قابل استفاده هستند. به این معنی که شما میتوانید به صورت مستقیم از یک متد کمکی که ایمپرت کرده اید بدون تعریف کردن آن در `methods` به صورت مستقیم در تمپلیت استفاده کنید:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ایپمرت ها هم به همین صورت قابل استفاده هستند. به این معنی که شما میتوانید به صورت مستقیم از یک متد کمکی که ایمپرت کرده اید بدون تعریف کردن آن در `methods` به صورت مستقیم در تمپلیت استفاده کنید:
ایمپورت‌ها هم به همین صورت قابل استفاده هستند. به این معنی که شما می‌توانید به صورت مستقیم از یک متد کمکی که ایمپورت کرده اید بدون تعریف کردن آن در `methods` به صورت مستقیم در تمپلیت استفاده کنید:

Comment on lines 84 to 86
MyComponent را یک referenced variable در نظر بگیرید. اگر تاکنون از JSX استفاده کرده اید، مدل فکری شبیه به همان است.
نوشتار kebab-case که می شود `<my-component>` در تمپلیت قابل استفاده است. اما استفاده از تگ های PascalCase بخاطر امکان تشخیص راحت تر از تگ های نیتیو خود HTML بیشتر توصیه می شود.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
MyComponent را یک referenced variable در نظر بگیرید. اگر تاکنون از JSX استفاده کرده اید، مدل فکری شبیه به همان است.
نوشتار kebab-case که می شود `<my-component>` در تمپلیت قابل استفاده است. اما استفاده از تگ های PascalCase بخاطر امکان تشخیص راحت تر از تگ های نیتیو خود HTML بیشتر توصیه می شود.
MyComponent را یک referenced variable در نظر بگیرید. اگر تاکنون از JSX استفاده کردهاید، مدل فکری شبیه به همان است.
نوشتار kebab-case که میشود `<my-component>` در تمپلیت قابل استفاده است. اما استفاده از تگهای PascalCase بخاطر امکان تشخیص راحت تر از تگهای بومی HTML بیشتر توصیه میشود.


```vue
<script setup>
import { useSlots, useAttrs } from 'vue'
import { useSlots، useAttrs } from 'vue'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { useSlots، useAttrs } from 'vue'
import { useSlots, useAttrs } from 'vue'


const slots = useSlots()
const attrs = useAttrs()
</script>
```

`useSlots` and `useAttrs` are actual runtime functions that return the equivalent of `setupContext.slots` and `setupContext.attrs`. They can be used in normal composition API functions as well.
`useSlots` و `useAttrs` در حقیقت runtime functions هستند که معادل `setupContext.slots` و `setupContext.attrs` می باشند. می توان آنها را در کامپوزیشن ای پی آی به عنوان توابع استفاده کرد.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`useSlots` و `useAttrs` در حقیقت runtime functions هستند که معادل `setupContext.slots` و `setupContext.attrs` می باشند. می توان آنها را در کامپوزیشن ای پی آی به عنوان توابع استفاده کرد.
`useSlots` و `useAttrs` در حقیقت runtime functions هستند که معادل `setupContext.slots` و `setupContext.attrs` میباشند. میتوان آنها را در Composition API به عنوان توابع استفاده کرد.

// declare additional options
export default {
inheritAttrs: false,
inheritAttrs: false،
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
inheritAttrs: false،
inheritAttrs: false,

- Do **NOT** use a separate `<script>` section for options that can already be defined using `<script setup>`, such as `props` and `emits`.
- Variables created inside `<script setup>` are not added as properties to the component instance, making them inaccessible from the Options API. Mixing APIs in this way is strongly discouraged.
- برای کارهایی که در `<script setup>` قابل انجام دادن هستند، از یک `script` جدا استفاده **نکنید**، مثل `props` و `emits`.
- متغیرهای ساخته شده داخل `<script setup>` به عنوان ویژگی های یک کامپوننت به کامپوونت اضافه نمی شوند، بنابراین قابلیت دسترسی به آنها در Options API وجود ندارد. استفاده همزمان از Options API و Composition API اشتباه است.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- متغیرهای ساخته شده داخل `<script setup>` به عنوان ویژگی های یک کامپوننت به کامپوونت اضافه نمی شوند، بنابراین قابلیت دسترسی به آنها در Options API وجود ندارد. استفاده همزمان از Options API و Composition API اشتباه است.
- متغیرهای ساخته شده داخل `<script setup>` به عنوان پراپرتی‌های یک کامپوننت محسوب نمیشوند، بنابراین امکان دسترسی به آنها در Options API وجود ندارد. استفاده همزمان از Options API و Composition API اشتباه است.


## Top-level `await` {#top-level-await}

Top-level `await` can be used inside `<script setup>`. The resulting code will be compiled as `async setup()`:
`await` می تواند در <`script setup`> استفاده شود. کد نهایی کامپایل می شود به `()async setup`:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`await` می تواند در <`script setup`> استفاده شود. کد نهایی کامپایل می شود به `()async setup`:
`await` میتواند در `<script setup>` استفاده شود. کد نهایی کامپایل میشود به `()async setup`:

Copy link
Member

@mostafa-nematpour mostafa-nematpour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

بابت مشارکتتون متشکرم 🌱

@mostafa-nematpour mostafa-nematpour merged commit 68481ca into vuejs-translations:main Apr 17, 2024
2 checks passed
@mostafa-nematpour mostafa-nematpour changed the title Api/sfc script setup script-setup Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants