Une collection organisée de snippets de code pour accélérer votre développement. Parcourez, recherchez et copiez en un clic.
<script setup>
import { ref } from 'vue'
const count = ref(0)
</script>
import { ref } from 'vue'
export default {
setup() {
const count = ref(0)
return { count }
}
}
<script setup>
const props = defineProps({
titre: String
})
</script>
<script setup>
const emit = defineEmits(['enlarge-text'])
emit('enlarge-text')
</script>
import { onMounted } from 'vue'
onMounted(() => {
console.log('le composant est monté.')
})
import { watch } from 'vue'
watch(count, (newCount) => {
console.log(`new count is: ${newCount}`)
})
watchEffect(() => {
console.log(count.value)
})
import { computed } from 'vue'
const plusOne = computed(() => count.value + 1)
// Parent
import { provide } from 'vue'
provide('message', 'bonjour')
// Enfant
import { inject } from 'vue'
const message = inject('message')
import { reactive } from 'vue'
const state = reactive({ count: 0 })
const count = ref(0)
function increment() {
count.value++
}