<div id="app">
Type the first number:
<input type="number" v-model.number="n1"><br />
Type the second number:
<input type="number" v-model.number="n2"><br />
The sum() is: {{ sum() }}<br />
The sum is: {{ sum2 }}
</div>
var app = new Vue({
el: "#app",
data: {
n1: 0,
n2: 0
},
computed: {
sum2: function () {
console.log('prop-> ' + this.n1 + '+' + this.n2);
return this.n1 + this.n2;
}
},
methods: {
sum: function () {
console.log('method-> ' + this.n1 + '+' + this.n2);
return this.n1 + this.n2;
}
}
});
This Pen doesn't use any external CSS resources.