这个是text不绑定:
<input type="text" v-model='text' />
<input type="text" v-model='title' />
<input type="text" v-model='title' />
<h4 v-bind="title">这里也会发生更新</h4>
"use strict"
function View(){
let proxy = new Proxy({},{
get(obj,property){},
set(obj,property,value){
console.log(value);
const els = document.querySelectorAll(`[v-model = "${property}"]`)
const els2 = document.querySelectorAll(`[v-bind = "${property}"]`)
els.forEach(item=>{
item.value = value
})
els2.forEach(item=>{
item.innerHTML = value
})
return true
}
})
this.init = function(){
const els = document.querySelectorAll('[v-model]')
console.log(els);
els.forEach(item=>{
item.addEventListener('keyup',function(){
proxy[this.getAttribute('v-model')] = this.value
});
});
}
}
new View().init()