Vue $parent অবজেক্ট
$parent অবজেক্ট প্যারেন্ট কম্পোনেন্টের Vue ইনস্ট্যান্স উপস্থাপন করে।
রুট এলিমেন্টে $parent অবজেক্ট ব্যবহার করা হলে $parent অবজেক্টের মান শূন্য হবে।
আপনার নিজস্ব Vue সার্ভার পান
চাইল্ড এলিমেন্টে $parent অবজেক্ট ব্যবহার করে প্যারেন্ট এলিমেন্টে 'টেক্সট' ডেটা অ্যাট্রিবিউট প্রতিস্থাপন করুন।
Example
<template>
<div>
<h3>Change Text</h3>
<p>Click the button to toggle the text in the PRE tag of the parent component.</p>
<button v-on:click="this.$parent.text='Hello!'">Change text in parent</button>
</div>
</template>
দ্রষ্টব্য:
নীচে আরো উদাহরণ দেখুন.
সংজ্ঞা এবং প্রয়োগ
$parent অবজেক্ট প্যারেন্ট কম্পোনেন্টের Vue ইনস্ট্যান্স উপস্থাপন করে।
রুট এলিমেন্টে $parent অবজেক্ট ব্যবহার করা হলে $parent অবজেক্টের মান শূন্য হবে।
আপনি $parent অবজেক্ট ব্যবহার করতে পারেন সরাসরি চাইল্ড কম্পোনেন্ট থেকে প্যারেন্ট ইনস্ট্যান্স অ্যাক্সেস করতে, কল করার পদ্ধতি, ডেটা বৈশিষ্ট্যগুলি পড়তে বা পরিবর্তন করতে এবং আরও অনেক কিছু।
দ্রষ্টব্য:
Vue উপাদানগুলির মধ্যে যোগাযোগের জন্য প্রপস/এমিট বা প্রদান/ইনজেক্ট ব্যবহার করার কথা বিবেচনা করুন, কারণ এগুলি স্পষ্টভাবে সংজ্ঞায়িত যোগাযোগ পাথের সাথে কোড বজায় রাখা সহজ।
আরো উদাহরণ
Example
চাইল্ড কম্পোনেন্টে $parent অবজেক্ট ব্যবহার করে প্যারেন্ট কম্পোনেন্টে একটি পদ্ধতি উল্লেখ করুন।
Template
<template>
<div>
<h3>Toggle Color</h3>
<p>Click the button to toggle the color in the P tag of the parent component.</p>
<button v-on:click="this.$parent.toggleColor">Toggle</button>
<p>The 'toggleColor' method is also in the parent component.</p>
</div>
</template>