import React from 'react'; import { ref, reactive } from '@vue/reactivity'; import { setup } from '../../src/index'; import './index.css'; interface TodoItem { title: string; done: boolean; } const Todo: React.FC = setup(() => { const todos = reactive([]); const inputValue = ref(''); const onSubmit = (e: React.FormEvent) => { e.preventDefault(); const title = inputValue.value; if (title) { todos.push({ title, done: false, }); } inputValue.value = ''; }; return props => { return ( <>
(inputValue.value = e.target.value)} placeholder="回车添加待办事项" />
); }; }); const TodoUl: React.FC<{ todos: TodoItem[] }> = setup(() => { return ({ todos }) => { const onToggle = (todo: TodoItem) => (todo.done = !todo.done); return (
    {todos.map((todo, index) => { return (
  • onToggle(todo)} key={index} > {todo.title}
  • ); })}
); }; }); export default Todo;