Vue3 使用 生命周期函数

<script>
  //引入生命周期函数 onMounted
import  {onMounted}  from "vue";
import axios from "axios";

export default {
  name: "Content",
  setup() {
    console.log("setup");
    //生命周期函数一定要在 setup中执行
    onMounted(()=>{
      console.log('a');
    });
  },
};
</script>

Vue3 使用 生命周期函数 

1.导入

2.在setup中使用

本文来自博客园,作者:咸瑜,转载请注明原文链接:https://www.cnblogs.com/bi-hu/p/15376417.html

原文地址:https://www.cnblogs.com/bi-hu/p/15376417.html