import { reactive } from 'vue'
const counter = reactive({
count: 0
})
console.log(counter.count) // 0
counter.count++
import { ref } from 'vue'
const message = ref('Hello World!')
console.log(message.value) // "Hello World!"
message.value = 'Changed'
<script setup>
import { ref, reactive } from 'vue'
// component logic
// declare some reactive state here.
const message = ref('Hello World!');
message.value="LEVEL";
const counter = reactive({
count: 5
});
</script>
<template>
<h1>{{ message.split('').reverse().join('') }} {{ counter.count }}</h1>
<h2></h2>
</template>
// VERSION 1
<div v-bind:id="dynamicId"></div>
// VERSION 2
<div :id="dynamicId"></div>
<script setup>
import { ref } from 'vue'
const titleClass = ref('title')
</script>
<template>
<h1 :class="titleClass">빨강색으로 클래스 적용</h1> <!-- add dynamic class binding here -->
</template>
<style>
.title {
color: red;
}
</style>
// VERSION 1
<button v-on:click="increment">{{ count }}</button>
// VERSION 2
<button @click="increment">{{ count }}</button>
<script setup>
import { ref } from 'vue'
const count = ref(0);
function increment(){
count.value++;
};
</script>
<template>
<!-- make this button work -->
<button @click="increment">count is: {{ count }}</button>
</template>
<script setup>
import { ref } from 'vue'
const text = ref('')
function onInput(e) {
text.value = e.target.value
}
</script>
<template>
<input :value="text" @input="onInput" placeholder="Type here">
<p>{{ text }}</p>
</template>
<script setup>
import { ref } from 'vue'
const text = ref('')
</script>
<template>
<input v-model="text" placeholder="Type here">
<p>{{ text }}</p>
</template>
<script setup>
import { ref } from 'vue'
const awesome = ref(true)
function toggle() {
awesome.value = !awesome.value
}
</script>
<template>
<button @click="toggle">toggle</button>
<h1 v-if="awesome">Vue is awesome!</h1>
<h1 v-else>Oh no 😢</h1>
</template>
https://vuejs.org/guide/introduction.html
https://vuejs.org/guide/essentials/forms.html