I would like to have some of the data
variables computed based on some other variables and follow their changes in the Vue
instance. The natural solution
new Vue({
el: '#root',
data: {
a: 1,
b: a + 1
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.0.3/vue.js"></script>
<div id="root">
{{ a }} and {{ b }}
</div>
fails with Uncaught ReferenceError: a is not defined
.
Is it possible to use previously defined variables to create new ones on the fly?