Last active
March 5, 2025 12:59
-
-
Save MaxMonteil/fc3008bd2717570481bbd9caeb3340c7 to your computer and use it in GitHub Desktop.
Basic Vue interview
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> | |
<h1>List items</h1> | |
<ul> | |
<li v-for="item in items" :key="item.id"> | |
{{ item.name }} | |
</li> | |
</ul> | |
<button @click="addItem">Add item</button> | |
</template> | |
<script setup> | |
import { ref } from 'vue' | |
const items = ref([ | |
{ name: "Item 1", id: 1 }, | |
{ name: "Item 2", id: 2 }, | |
{ name: "Item 3", id: 3 }, | |
]) | |
function addItem() { | |
const id = items.length + 1 | |
items.push({ name: `Item ${id}`, id }) | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
React version: