Is the vue-property-decorator triggering a mutation in the Prop?

I am currently using the 'vue-property-decorator' in my simple component, but I encountered an error message:

[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "message"

Can someone please explain what this message means and how I can resolve this issue?

Below is an example of my code:

<template>
    <v-layout row justify-center>
        <v-dialog v-model="dialog">........</v-dialog>
    </v-layout>
</template>

<script lang="ts">
import { Component, Prop } from 'vue-property-decorator';

@Component({})
export default class SomeModal extends ... {

  @Prop() public dialog?: boolean;
  @Prop() public message?: string;

  constructor() {
    super();
  }

  public showError(er) {
    this.message = er.message;
    this.dialog = true;
  }
}
</script>

<style scoped lang="scss">
</style>

Answer №1

I haven't encountered this particular syntax for Vue before, but the message is clear: you must define a data property or a computed variable. This means either:

data: {
    dialogData: ''
}

constructor() {
    super();
    this.dialogData = this.dialog;
}

or :

computed: {
    dialogData() {
        return this.dialog;
    }
}

Refer to the Vue.js documentation on computed properties for more information.

Edit: with vue-property-decorator, it could be:

@Component
export default class YourComponent extends Vue {
  // your code here...
  private _dialogData: string = '';

  constructor() {
      super();
      this._dialogData = this.dialog;
  }
}

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

Angular's created by directive will only receive updates and not update any other components

My directive is not updating the <select> element itself when the ng-model scope variable is changed, but it does update when I change the scope variable bound to it. I believe I may need to register a $watch in the link function, but I'm uncert ...

Can a CSS template be incorporated into a Vue component?

I have recently developed a Vue component that serves as a loading screen: var loading = new Vue({ el: "#loading_id", components:{ 'loading' : { template : ` <div> <div ...

How to receive a response from PHP using AJAX

-- jQuery AJAX and PHP CodeIgniter Integration var User = function(){ return { init : function(){ document.getElementById('login').addEventListener('click', this.login); }, login : function(){ ...

Modifying an image's height and width attributes with jQuery and CSS on click action

I'm currently developing a basic gallery using HTML, CSS, and jQuery. The objective is to have a larger version of an image display in a frame with an overlay when the user clicks on it. While this works flawlessly for horizontally-oriented images, ve ...

AngularJS: Tips for Waiting in the 'Run' Method until Completion

I am facing a simple issue - I want to set up my http calls with an interceptor that will include a token in the headers. The challenge is that the token is received through an http call as well (which should be the initial call), and I'm unsure how t ...

What is the most compatible JavaScript framework for openlayers?

I'm seeking guidance on selecting a front-end framework (e.g. React, Vue, Angular) that is compatible with OpenLayers for my upcoming implementation. Could you please recommend the most suitable front-end framework to work seamlessly with OpenLayers? ...

"Double the Data: A D3.js JSON Tale of Two Creators

I found inspiration from this example: http://bl.ocks.org/mbostock/1062288 to create a collapsible Force Layout. One challenge I'm facing is how to display a graph where a single node is connected to two parent nodes. father father | | ...

Issue when sending PHP Papa Parse object through AJAX

I am currently working on extracting a CSV local file in PHP using AJAX and have found success with Papa Parse. However, I am facing difficulties passing the results with AJAX. Despite trying various methods such as JSON.stringify, passing only the first f ...

Combining React, Typescript, and asynchronous Promises

Currently I am in the process of developing a component that interacts with a webservice to fetch data asynchronously using promises. Once the promise is fulfilled, I intend to integrate the results into my component's rendering method. My ultimate go ...

Choosing the Following Date from the Datepicker using Selenium IDE

I need the selenium IDE test case to automatically select a date following the steps outlined below: Start by clicking on the departure date to open the datepicker Loop through the dates starting with the currently selected day until the next available d ...

Using Angular as a template engine: A simple guide

My goal is to utilize Angular as a template engine and then pass the resulting HTML code to another library. In my template file named template.html: <div><h1><span data-ng-show="details.rs">{{details.rs}}</span></h1></di ...

Text at the center of a series of circles on canvas

Can someone assist me in aligning my text at the center of 5 concentric circles? Below is the code I have written, but it doesn't seem to be working. Any suggestions on what modifications I need to make to achieve this would be greatly appreciated. Th ...

Learn how to redirect email recipients to a separate page when they click on the email subject line

Currently, I am working on developing an inbox feature in PHP where it shows the Mail Id and Subject. When a user clicks on a specific division containing the mail id and subject, it should navigate to a new page in PHP that displays the body and attachmen ...

Having trouble getting datatables.net to function properly with JavaScript

I've been experimenting with datatables from http://datatables.net/ Attempting to make it work using javascript, but I'm facing issues. Even when following the example provided on the website, it still shows a blank page. Does anyone have any su ...

"Implementing a seamless transition effect on two slideshows using jQuery's fadeslideshow

I currently have a homepage featuring a fadeslideshow with 5 slides. The fadeslideshow plugin being used can be found at http://plugins.jquery.com/project/fadeslideshow. On the homepage, there is also a menu bar with various menu items. When a user clicks ...

Javascript - Editing specific markers with varying titles from the url

My website contains checkboxes in the html code: <input onclick="markAsChanged(this); toggleApproveDeny(this);" name="2c9923914b887d47014c9b30b1bb37a1_approveChk" type="checkbox"> <input onclick="markAsChanged(this); toggleApproveDeny(this);" na ...

Omit words from list in a route in Express.js

When working with the Express.js Framework, I am faced with a scenario where I have the following route defined: app.post('/:username/:slug', user.fn); I am now looking for a solution to create a regular expression that can validate if the slug ...

What is the best way to iterate through array elements with AngularJS?

I am looking to showcase array values using the ng-repeat directive, and then call the getimage function with itemid and photoidlist in order to retrieve the image URL. The JSON data that I have is as follows: $scope.productslist = { "json": { "re ...

The issue of JQuery recursion not properly focusing on a textbox

Can anyone help with a jquery focus issue I'm experiencing? My goal is to address the placeholder problem in IE by focusing on an element and then blurring it to display the placeholder. This functionality is being used in a modal form. Initially, e ...

Tips for transferring an array from a php page to a javascript page

In my PHP code, I have an array structured like this: 1) <body onload="addMarkers(<?php print_r($myArray) ?>)"> 2) <body onload="addMarkers(<?php echo json_encode($myArray) ?>)"> Unfortunately, these attempts were unsuccessful. U ...