I declared a variable in data through a class, passed it as props to a child component, and called the class method in the child component, changing the variable in the class. Is it worth doing this in vue 2? On the one hand, this is a props mutation, on the other, vue does not swear at the props mutation
an example of what I mean https://plnkr.co/edit/NcnaATfD3zGiY7x2?open=lib%2Fscript.js&preview
class User {
name = 'initial name'
setName (name) {
this.name = name
}
}
Vue.component('child', {
props: ['user'],
template: '<div><input @input="user.setName($event.target.value)"/></div>'
})
var app = new Vue({
el: '#app',
data () {
return {
msg: 'vue inst',
user: new User()
}
},
template: '<div>{{user.name}}<child :user="user"/></div>'
})
I thought that vue 2 would give an error about the prop mutation, but everything is fine. I can’t find a direct answer to my question, but there is a feeling that this is a bad practice