-
-
Save cursosdesarrolloweb/a65e09959c079fa5ecc1e18fe2f57449 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/jsx"> | |
import { reactive, toRefs, defineComponent } from "vue"; | |
const App = defineComponent({ | |
setup() { | |
const form = reactive({ | |
username: "", | |
password: "" | |
}) | |
const formToRefs = toRefs(form) | |
return () => ( | |
<> | |
<DynamicInput | |
placeholder="Username" | |
model={formToRefs.username} | |
styles={{ padding: "10px", backgroundColor: "#111", color: "#fff", fontWeight: "bold" }} | |
/> | |
<p>Model: {formToRefs.username.value}</p> | |
<DynamicInput | |
placeholder="Password" | |
type="password" | |
model={formToRefs.password} | |
styles={{ padding: "10px", backgroundColor: "#222", color: "#fff", fontWeight: "bold" }} | |
/> | |
<p>Model: {formToRefs.password.value}</p> | |
</> | |
); | |
}, | |
}); | |
export default App | |
const DynamicInput = ({model, placeholder, styles, type = "text"}) => ( | |
<input style={styles} type={type} placeholder={placeholder} v-model={model.value} /> | |
) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment