P24. vue3 组合式api语法糖

image.png

  • App.vue
<script setup>
import Content from "./components/Content.vue";
</script>

<template>
  <div>
    <Content />
  </div>

</template>

image.png

image.png

image.png

定义相应式变量还是需要vue引入
<script setup>
import Content from "./components/Content.vue";
import { ref } from "vue";
const b=ref(100000)
const a=20;
console.log(a);
</script>

<template>
  <div>
    <h2>{{a}}</h2>
    <h2>{{b}}</h2>
    <Content />
  </div>

</template>


image.png

image.png

image.png

评论

暂无评论