I have this code. It's purely for experimental purposes :
test.html
<div id="example-1">
{{ stuff.dosobject.notlist }}
<button v-on:click="dostuff">DO STUFF</button>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>
<script src="test.js"></script>
test.js
var oneobject={
dosobject:{
notlist:"foo"
}
}
var stuff = Object.create(oneobject)
var example1 = new Vue({
el: '#example-1',
data: {
stuff:stuff
},
methods:
{
dostuff:function(event)
{
if(stuff.dosobject.notlist=="foo")
stuff.dosobject.notlist="bar"
else
stuff.dosobject.notlist="foo"
}
}
})
The object stuff is created with oneobject as a prototype.
I would expect the property stuff.dosobject.notlist to be reactive, ie the {{ stuff.dosobject.notlist }} part of the template to be re-rendered when the button is clicked.
It doesn't seem to be the case.
Am I doing something wrong ? Or is it normale VueJS behavior?
After thinking a bit about it, It would not seem so weird to not make all prototype properties reactive because the prototype chain can be quite long and cause performance issues.