<template>
<div>
<span>count is {{ count }}</span>
<span>plusOne is {{ plusOne }}</span>
<button @click="increment">count++</button>
</div>
</template>
<script>
import { value, computed, watch, onMounted } from 'vue'
export default {
import { reactive,value,computed,watch,onMounted } from 'vue'
setup(props,{emit}) {
const count = value(0)
const state = reactive({
username: '',
password: ''
})
const plusOne = computed(() => count.value + 1)
const increment = () => { count.value++ }
watch(() => count.value * 2, val => {
console.log(`count * 2 is ${val}`)
})
onMounted(() => {
console.log(`mounted`)
})
return {
state,
count,
plusOne,
increment
}
}
}
</script>