search

Home  >  Q&A  >  body text

javascript - vue.js assignments are all two-way binding. How to only assign values ​​but not two-way binding?

The data in vue is two-way bound.
But I don’t want to bind, I just want to assign the value to vue, but the original attributes remain unchanged, that is, one-way assignment?

var v = new Vue({el: "#a",data:{ a: ''}

})

开始 a = '';
var b = 2;
v.a = b;

v.a = 3; // 这里b也等于3了

我想
v.a =3; // 但是b还是等于2

What method is used to assign values?

三叔三叔2744 days ago979

reply all(3)I'll reply

  • 淡淡烟草味

    淡淡烟草味2017-06-15 09:23:41

    Two-way binding only works in templates

    reply
    0
  • 漂亮男人

    漂亮男人2017-06-15 09:23:41

    b will not also be equal to 3

    reply
    0
  • PHP中文网

    PHP中文网2017-06-15 09:23:41

    Put the code on codepen and reproduce it?

    reply
    0
  • Cancelreply