// 虚拟dom 数据对象类
class myElement {
constructor(type, props, children) {
this.type = type;
this.props = props;
this.children = children;
}
}
//
function myElement(type, props, children) {
return new vnode(type, props, children)
}
function createDom(mNode) {
let el= document.createElement(mNode.type);
for(let key in mNode.props){
if(key==='value'){
if(mNode.type.toLowerCase()==='INPUT'||mNode.type.toLowerCase()==='TEXTAREA')
el.value= mNode.props[key]
}else{
el.setAttribute(el,node.props[key])
}
}
return el
}
// 未完成,明天继续 https://www.jianshu.com/p/c43900522c27