- IT Tips
- Ruby / Rails以外の開発一般
READ MORE
watch
で変数の変更を監視しています。watch
の内部で変数をさらに変更しても無限ループになりません。
const vm = new Vue({
el: "#app",
data: {a: "", b: ""},
watch: {
a: function(v) {
this.a = v.replace(/[A-Za-z0-9]/g, function(s) { return String.fromCharCode(s.charCodeAt(0) + 65248) })
},
b: function(v) {
this.b = v.replace(/[A-Za-z0-9]/g, function(s) { return String.fromCharCode(s.charCodeAt(0) - 65248) })
},
},
})