managing data transmission in Vue

Seeking assistance as a Vue beginner, I am struggling with passing props between components and could use some guidance.

events.js

 props: ["id", "event"],

defined the props

data: function() {
    return {
      regular: null,
      event:"",
     
    };
    
  },

Passed it

 <h1 class="modal__text">{{ event.name}}</h1>

Running into an issue that says "Duplicate key". How can I correct this error?

Answer №1

To avoid conflicts, it is important to ensure that data and props do not share the same name in your code. Make sure to remove any instances of event from your data section. Instead, consider setting a default value for your props like this:

props : {
   ...
   event : {
       type : 'Object',
       default : function(){
           return {
               name : ''
               // add additional fields here
           };
       }
   }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilizing FullCalendar for showcasing comprehensive details

I'm a big fan of the fullcalendar plugin and all its amazing features. I want to enhance it by displaying more customized information for each event when in agendaWeek or agendaMonth view. Switching between views is easy, but I need help filtering out ...

Testing the throwing of errors when running Karma by utilizing sinon.spy on global functions like parseInt

I'm currently facing an issue with monitoring the usage of parseInt within my function. This is a Proof of Concept for integrating TypeScript into our company's workflow. I've tried following two different tutorials on testing Sinon, but no ...

Having trouble retrieving PHP variable values using JavaScript?

<div id="div01">01</div> <div id="div02">02</div> <img src="../img/logo.png" onclick="blueSky()"/> js function blueSky() { $.ajax({ type:'GET', url: 'test.php', success: function(respond) { document.ge ...

Managing embedded URLs in Next.js applications

I am currently in the process of developing an ecommerce platform, expecting users to utilize both our domain and their own custom domains. For example: ourplatform.com/username theirdomain.com My goal is to customize the inline links based on the speci ...

Executing multiple functions in a specific order within an asynchronous grunt task using async

I am facing an issue with my grunt tasks that run asynchronously using this.async. I have some asynchronous functions in the code and for a few tasks, I need them to run in series. To achieve this, I am utilizing async.series from the async npm module. How ...

"Learn how to easily send media files stored on your local server via WhatsApp using Twilio with Node.js and Express

Whenever I attempt to send the PDF file created through WhatsApp, an error pops up preventing me from viewing it. easyinvoice.createInvoice(data, function(result) { //The response will contain a base64 encoded PDF file ...

Can an iterated element be used as an object key in the data property within a "v-for" loop?

My situation is similar to this: v-for="i in 10" new Vue({ el: '#app', data: { howManyRow: null, date: { 1: Sat Dec 28 2019 00:00:00 GMT+1100 (Australian Eastern Daylight Time), 2: Sat Dec 28 2019 00:00:00 GMT ...

Blank Screen with Three JS Animation

I'm relatively new to three js and webgl. Currently, I'm working on a complex solar system project and everything seems to be functioning well until I attempt to animate anything. Below is a simplified version showcasing the issue (with a low res ...

Is it possible to activate the identical drop-down or popover with multiple buttons?

Is it possible to activate the same drop-down menu with multiple buttons? For example, I want a button at the top of the page labeled special menu, another in the middle also labeled special menu, and one at the bottom as well labeled special menu. When a ...

What is the best way to initiate a local Node.js server specifically when launching a desktop Electron application?

I am looking to ensure that my node js server runs while my electron app is open. One method I have attempted is using the child_process module to execute a shell command as shown below: const {exec} = require('child_process') const startDBServ ...

Verify the dialog box return with a text input box

I am trying to implement a confirmation dialog box for when a user wants to delete their account. This dialog box requires the user to enter their password in a textbox. However, I am struggling with catching the postback event and executing the relevant m ...

Creating an aperture in a form using a different shape in THREE.js

Currently, I am utilizing the D3-threeD2.js library to convert SVG files into THREE.Shape(s) that can be extruded with three.js. The process works smoothly, however, when it comes to incorporating holes, I encounter an issue. Imagine a shape resembling a ...

Changing an array in JavaScript within a function

When working with arrays in JavaScript, how can I mutate the value of an array inside a function? I'm aware that certain array methods can achieve this, but regular assignment doesn't seem to work. var arr = [4]; function changeArray(arr) { ...

What is the best way to deactivate the onclick event after it has been triggered?

There was an image that triggered the add_cart() JavaScript function when clicked using onclick() <img src="images/add.png" onclick="add_cart()"> The goal is to limit the user to clicking the image only once. Upon the first click, the add_cart func ...

Employing an odd/even toggle for assigning class names

I need each this.state.title to be aligned based on a different classname. I attempted using css flex boxes/nth-of-type/nth-child, but it didn't work well with React. I'm utilizing this.state to access my objects. My failed strategy render: f ...

Discovering the Secrets of Accessing and Modifying Item Values in BIRT

Is it feasible to create using only Javascript without utilizing any Java functions? Is there a way to access values from elements like labels, tables, or charts by calling them from an HTML button? I am currently working with Openlayers and BIRT. I need ...

Presentation with multi-directional animations

Curious to know if it's possible to create a unique slideshow that scrolls in multiple directions? The concept is to display various projects when scrolling up and down, and different images within each project when scrolling left and right. Is this i ...

Bot in discord.js refuses to exit voice channel

I've been struggling to get my bot to leave the voice channel despite trying multiple methods. Here's what I've attempted in the source code: Discord.VoiceConnection.disconnect(); Although this is the current code, I have also tested: messa ...

Each time a user drags and drops, I aim to save an ID to the localStorage

I am faced with a challenge involving two panels. In the left panel, there are multiple cards each with a unique id assigned to them as an attribute in the div element. When a user performs drag and drop action over to the other panel, I successfully use t ...

Showcasing two sets of data from an array using chart.js within a node.js environment

I am currently working on a project where I need to display two elements from an array - one as the label (e.g. "name of certain type of crop") and the other as the data itself (e.g. "quantity of the crop"). However, I am facing an issue where if the same ...