Hi everyone! I'm the author of code.mu :)
I'd love to chat with my non-Russian audience. I'm looking for your feedback on the site and the translation quality. Let's chat:)
⊗jsvuPmCmRE 69 of 72 menu

Vue में कंपोनेंट डेटा की रिएक्टिव एडिटिंग

आइए अब हमारे चाइल्ड कंपोनेंट्स के डेटा की एडिटिंग लागू करते हैं। सबसे पहले पैरेंट कंपोनेंट में उसके id के आधार पर यूजर को बदलने की मेथड बनाएं:

methods: { change(id, name, surn) { this.users = this.users.map((user) => { if (user.id === id) { user.name = name; user.surn = surn; } return user; }); } }

लूप में कंपोनेंट्स बनाएं, उन्हें पैरामीटर के रूप में नाम, उपनाम, id और बदलने की मेथड पास करें:

<template> <User v-for ="user in users" :id ="user.id" :name ="user.name" :surn ="user.surn" :key ="user.id" @change="change" /> </template>

चाइल्ड कंपोनेंट की सेटिंग emits में इमिट की जाने वाली इवेंट लिखें:

props: { id: Number, name: String, surn: String, }, emits: ['change'],

अब चाइल्ड कंपोनेंट में एक प्रॉपर्टी बनाएं जो कंपोनेंट के मोड को सेट करेगी, दिखाना या एडिट करना:

data() { return { isEdit: false, } }

एडिटिंग के लिए इनपुट्स के काम को सपोर्ट करने के लिए प्रॉपर्टीज भी बनाएं:

data() { return { isEdit: false, newName: '', newSurn: '', } }

ऐसा करें कि इन प्रॉपर्टीज के शुरुआती वैल्यू प्रॉप्स से लिए जाएं:

data() { return { isEdit: false, newName: this.name, newSurn: this.surn, } }

एक मेथड बनाएं जो एडिट मोड शुरू करेगी:

methods: { edit() { this.isEdit = true; } }

एक मेथड बनाएं जो एडिट किए गए डेटा को सेव करेगी, और साथ ही एडिट मोड को बंद कर देगी:

methods: { save() { this.isEdit = false; this.$emit('change', this.id, this.newName, this.newSurn); } }

चाइल्ड कंपोनेंट का व्यू बनाएं:

<template> <template v-if="!isEdit"> {{ name }} {{ surn }} <button @click="edit"> edit </button> </template> <template v-else> <input v-model="newName"> <input v-model="newSurn"> <button @click="save"> save </button> </template> </template>

Employee कंपोनेंट के डेटा की एडिटिंग लागू करें।

हिन्दी
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEnglishEspañolEestiSuomiFrançaisMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
हम साइट के कार्य, विश्लेषण और व्यक्तिगतकरण के लिए कुकीज़ का उपयोग करते हैं। डेटा प्रसंस्करण गोपनीयता नीति के अनुसार किया जाता है।
सभी स्वीकार करें कॉन्फ़िगर करें अस्वीकार करें