vuejs prop value variable value code example

Example 1: vue prop string or number

props: {
        users_count: {
            type: [Number, String],
            required: true
        }
    },

Example 2: vuejs change prop value

//In your component (here TaskTemplate.vue)
methods: {
  add() {
    this.$emit('add-counter', this.taskId);
  }
}

//In App.vue



//...
data() {
  return {
    task: {
      id: 0,
      name: 'Empty been',
      counter: '2'
    }
  }
}

methods: {
	addTaskCounter(taskId) {
  		const identifiedTask = this.tasks.find((task) => task.id === taskId);

  		identifiedTask.counter += 1;
  	}
}

Tags:

Misc Example