I want to write in VUE as well as js or jquery but this framework have some secrets i do not discover yet. I want to make simple loop for and function but i can just make the simplest calculation. I write somethink like that and this calculator work perfect:
data: {
pv: {
p: '',
pd: '',
d: '',
u: '',
w: '',
},
},
methods: {
calc: function () {
var d = this.pv.d
var p = this.pv.p
var u = this.pv.u
var w = this.pv.w
this.pv.pd = p - d;
this.pv.w = this.pv.pd - u;
},
but i want to have something more advance:
this.pv.w = function(){if(w < 1000){return 1000-u;}else{w-u;}}
in simple js it would work perfect but i do not understand VUE framework as well. Or a loop for
this.pv.w = function(){for(i=0;i<10;i++){var s = u*i;}}
This is easy task i do not find in their documentation
just find that loop is {{n in 50}} but i want have calculation od "js side" then put in to html dom if i want to.
Some hints on how to use the variables in vue:
data() return {
pv: {
p: '',
pd: '',
d: '',
u: '',
w: '',
},
},
methods: {
calc1() { // no function keyword required
let pv = this.pv; // shorthand
pv.d = pv.p - pv.d;
pv.w = pv.pd - pv.u;
},
calc2() {
let pv = this.pv;
if(pv.w < 1000){
pv.w = 1000 - pv.u;
} else {
pv.w = pv.w - pv.u;
}
},
calc3() {
let pv = this.pv;
for(let i=0; i<10; i++){
pv.w += pv.u*i;
}
}