This file contains hidden or 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
<template> | |
<button @click="$emit('change')"> Click Me </button> | |
</template> | |
<script setup> | |
import { defineProps, defineEmit, useContext } from 'vue' | |
const props = defineProps({ | |
foo: String, | |
}) | |
const emit = defineEmit(['change', 'delete']) |
This file contains hidden or 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 setup> | |
const post = await fetch(`/api/pics`).then((a) => a.json()) | |
</script> |
This file contains hidden or 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> | |
performGlobalSideEffect() | |
// this can be imported as `import { named } from './*.vue'` | |
export const named = 1 | |
</script> | |
<script setup> | |
// code here | |
</script> |
This file contains hidden or 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> | |
import { ref, computed } from 'vue' | |
export default { | |
setup () { | |
const a = ref(3) | |
const b = computed(() => a.value + 2) | |
const changeA = () => { a.value = 4 } | |
return { a, b, changeA } // have to return everything! |
This file contains hidden or 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 setup> | |
import { ref, computed } from 'vue' | |
// all of these are automatically bound to the template | |
const a = ref(3) | |
const b = computed(() => a.value + 2) | |
const changeA = () => { a.value = 4 } | |
</script> |
This file contains hidden or 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
<template> | |
<component-b /> | |
</template> | |
<script setup> | |
import ComponentB from './components/ComponentB.vue' // really that's it! | |
</script> |
This file contains hidden or 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 setup> | |
import HelloWorld from './components/HelloWorld.vue' | |
// This starter template is using Vue 3 experimental <script setup> SFCs | |
// Check out https://github.com/vuejs/rfcs/blob/script-setup-2/active-rfcs/0000-script-setup.md | |
</script> |
This file contains hidden or 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
<template> | |
<div> | |
<p> Wrapper for a text input </p> | |
<input | |
type="text" | |
placeholder="Custom input!" | |
/> | |
</div> | |
</template> |
This file contains hidden or 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
<template> | |
<div> | |
<p> Wrapper for a text input </p> | |
<input | |
type="text" | |
placeholder="Custom input!" | |
@change='$emit("customChange", $event.target.value)' /* INLINE EMIT! */ | |
/> | |
</div> | |
</template> |
This file contains hidden or 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
<template> | |
<my-input @custom-change="logChange"/> | |
</template> | |
<script> | |
import MyInput from './components/MyInput.vue' | |
export default { | |
components: { | |
MyInput | |
}, |