I have single file component. I need create variable like to 'data' but non reative PER component (not sharing between the same components). How can i do it in vue ?
// my-component.vue
export default {
data() {
return {
reative: 1
};
},
// psevdocode
myNonObservableVariables(){
return {
simpleField: 3
}
},
methods: {
method1() {
// can set
this.simpleField = 5;
}
method2() {
// can get
console.log(this.simpleField);
}
}
Update 1: Example i create 2 components and assign random value to 'simpleField' and log to console, i need:
<my-component></<my-component> // console.log -> 555
<my-component></<my-component> // console.log -> 666
after in first component call method which assign new value = 999, after this :
<my-component></<my-component> // console.log -> 999
<my-component></<my-component> // console.log -> 666