Skip to content

一个简单的virtual-dom实现,只有不到500行,支持类似react的自定义组件功能。

Notifications You must be signed in to change notification settings

linlifengx/simple-vdom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

simple-vdom

一个简单的virtual-dom实现,只有不到500行,支持类似react的自定义组件功能。


简单的例子

const Component = vdom.Component
const h = vdom.h

class App extends Component {
    constructor () {
        super()

        this.state = {
            value: ''
        }

        this.onInput = (event) => {
            this.setState({
                value: event.target.value
            })
        }
    }

    render () {
        return h('div', null, [
            h('input', {value: this.state.value, onInput:this.onInput}),
            h('div', null, this.state.value)
        ])
    }
}

vdom.mount(document.querySelector('#app'), new App())

TodoMVC Demo

https://linlifengx.github.io/demos/simple-vdom-todo-mvc/index.html

About

一个简单的virtual-dom实现,只有不到500行,支持类似react的自定义组件功能。

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published