任何人都可以给我有关 vue 3 中可重用组件输入的提示吗?在 React 中就像这样:
可以说,
<Input />在父组件中使用可重用组件import { useState } from 'react';
import Input from './component/Input';
function Home() {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const handleSubmit = (e) => {
e.preventDefault();
console.log(email, password);
}
return (
<form onSubmit={handleSubmit}>
<Input id="email" labelText="Email" value={email} onChange={e => setEmail(e.target.value)} />
<Input id="password" labelText="Password" value={password} onChange={e => setPassword(e.target.value)} />
<button type="submit">Login</button>
</form>
);
}
Run Code Online (Sandbox Code Playgroud)
<Input />组件:export default function Input(props) {
const { id, …Run Code Online (Sandbox Code Playgroud)