选项式API_生命周期
bash
<template>
<h3>选项式API</h3>
<p>{{ message }}</p>
</template>
<script>
export default {
data(){
return{
message:""
}
},
mounted(){
this.message = "选项式API生命周期函数"
}
}
</script>
组合式API_生命周期
bash
<template>
<h3>组合式API</h3>
<p>{{ message }}</p>
</template>
<script setup>
import { ref,onMounted } from "vue"
const message = ref("")
onMounted(() =>{
message.value = "选项式API生命周期函数"
})
</script>