$('body').html('');
let vnode = document.createElement('div');
let content = document.createTextNode('123');
vnode.appendChild(content);
$('body').append(vnode);
document.addEventListener('mousemove',e=>{
vnode.location = `x:${e.screenX};y:${e.screenY}`;
})
Object.defineProperty(vnode,'location',{
get(){return {x:Window.screenX,y:Window.screenY}},
set(value){
vnode.innerHTML = value;
}
})
打开百度粘到console里 随便玩玩,试试defineProperty
网友评论