vue3.0之初体验
直接上代码
<template>
<div class="text">
<h1>当前数值:{
{ count }}</h1>
<h2>当前数值 * 2:{
{ doubleCount }}</h2>
<h3>vuex中的数值a:{
{ a }}</h3>
<button @click.stop="add">添加</button>
<button @click.stop="update">更新vuex中的a</button>
</div>
</template>
<script>
import { ref, computed, watch, getCurrentInstance } from 'vue'
export default {
setup() {
const count = ref(0);
const add = () => {
count.value++
}
watch(() => count.value, val => {
console.log(`count is ${val}`)
})
const doubleCount = computed(() => count.value * 2)
const { ctx } = getCurrentInstance()
console.log(ctx.$router.currentRoute.value)
const a =