Bakhodir
Bakhodir

Reputation: 33

Passing a value from function to data() vuejs

I have emmited data from a component and I want to pass this data in data() function.

Here's what I mean

    export default {
  name: "App",
  data() {
    return {
      newlist
    };
  },
  components: {
    InputForms,
    List
  },
  methods: {
    handler(obj) {
      obj = this.newlist;
    }
  }
};

I want obj inside my handler method to be inside data(). Right now,this code is not compiling saying that newlist is not defined

Upvotes: 0

Views: 65

Answers (1)

Dan Knights
Dan Knights

Reputation: 8378

Change newlist to newlist: {} then inside your method swap what you already have:

handler(obj) {
   this.newlist = obj;
}

Upvotes: 1

Related Questions