<template>
<div class="container">
<p>{
{count}}</p>
<p>{
{double}}</p>
<button class="btn btn-primary" @click="add" type="submit">+</button>
</div>
</template>
<script lang="ts">
import { defineComponent, computed ,ref} from 'vue';
import 'bootstrap/dist/css/bootstrap.min.css'
import axios from 'axios'
// 就会提供些额外的方法
export default defineComponent({
name: 'App',
// setup 方 法还不能为空,真的很奇葩的事情
setup(){
const count = ref(100);
const double = computed(()=>{
return count.value* 2;
})
const add = ()=>{
count.value ++;
}
return {
count,
double,
add
}
}
});
</script>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoo
vue3 计算属性的写法
最新推荐文章于 2024-07-24 22:25:19 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)