Example
আপনার নিজস্ব Vue সার্ভার পান
'হ্যালো!' <slot-comp> উপাদানের মধ্যে 'bottomSlot' নামের স্লটে বার্তা পাঠানোর জন্য v-slot নির্দেশিকা ব্যবহার করে।
<slot-comp v-slot:bottomSlot>'Hello!'</slot-comp>
নীচে আরো উদাহরণ দেখুন.
Definition and Usage
ভি-স্লট নির্দেশিকাটি নামযুক্ত স্লটে বিষয়বস্তু পরিচালনা করতে ব্যবহৃত হয়।
ভি-স্লটের সংক্ষিপ্ত রূপ: হল #।
ভি-স্লট নির্দেশিকাটি চাইল্ড কম্পোনেন্টে ভি-বাইন্ড ব্যবহার করে প্রদত্ত স্কোপড স্লট থেকে ডেটা পুনরুদ্ধার করতেও ব্যবহার করা যেতে পারে।
ভি-স্লট উপাদানে বা নেস্টেড <টেমপ্লেট> উপাদানে ব্যবহার করা যেতে পারে।
v-স্লট <টেমপ্লেট> উপাদানগুলিতে ব্যবহৃত হয় যখন আপনি একটি উপাদানের একাধিক স্লটে সামগ্রী বরাদ্দ করতে চান।
More Examples
Example 1
একই উপাদানের দুটি ভিন্ন স্লটে বিষয়বস্তু বরাদ্দ করতে <টেমপ্লেট> উপাদানগুলিতে ভি-স্লট ব্যবহার করে।
App.vue:
<template>
<h1>App.vue</h1>
<p>The component has two slots, and the template element is used to assign content to both.</p>
<slot-comp>
<template v-slot:topSlot>
<div>
<p>Tigers are beautiful!</p>
<img src="tiger.svg" alt="tiger" width="100">
</div>
</template>
<template v-slot:bottomSlot>
<div>
<p>Whales can be very big</p>
</div>
</template>
</slot-comp>
</template>
SlotComp.vue:
<template>
<hr>
<h3>Component</h3>
<slot name="topSlot"></slot>
<slot name="bottomSlot"></slot>
</template>
Example 2
ডিফল্ট স্লটে বিষয়বস্তু চালাতে ভি-স্লট ব্যবহার করা।
SlotComp.vue:
<h3>Component</h3>
<div>
<slot></slot>
</div>
<div>
<slot name="bottomSlot"></slot>
</div>
App.vue:
<h1>App.vue</h1>
<p>The component has two div tags with one slot in each.</p>
<slot-comp v-slot:default>'Default slot'</slot-comp>
Example 3
v-slot: সংক্ষেপণ # ব্যবহার করে।
App.vue:
<h1>App.vue</h1>
<p>The component has two div tags with one slot in each.</p>
<slot-comp #topSlot>'Hello!'</slot-comp>
SlotComp.vue:
<h3>Component</h3>
<div>
<slot name="topSlot"></slot>
</div>
<div>
<slot name="bottomSlot"></slot>
</div>
Example 4
স্কোপড স্লট থেকে ডেটা পেতে ভি-স্লট ব্যবহার করা।
App.vue:
<slot-comp v-slot="dataFromSlot">
<h2>{{ dataFromSlot.lclData }}</h2>
</slot-comp>
Exercise
প্রশিক্ষণ:
Vue.js v-slot: ?