阅读 108

这可能才是你最想要的 Vue 3.0!

我基于 React hooks 提前实现了类似 Vue 3.0 的 Function-based API,或许这才是你最想要的 Vue 3.0,而且这些 API 都是类型安全的哦:

import React from 'react'
import { value, useState, useEffect, render } from 'rve'

function App() {
  const count = value(0)

  const state = useState({
    user: {
      name: 'yetone',
    },
  })

  const incr = () => count.value++

  useEffect(() => {
    document.title = `${state.user.name} clicked ${count.value} times`
  })

  return (
    <div>
      <p>{state.user.name} clicked {state.count} times</p>
      <input type="text" value={state.user.name} onChange={e => state.user.name = e.target.value} />
      <button onClick={incr}>Click me</button>
    </div>
  )
}

render(<App />, document.getElementById('app'))
复制代码

欢迎 star:github.com/yetone/rve

文章分类
前端
文章标签