当前位置: 首页 > news >正文

比较好的网站开发框架深圳seo论坛

比较好的网站开发框架,深圳seo论坛,seo网站分析案例,以用户为中心 建设学校网站1.vue3生命周期官方流程图 2.vue3中的选项式生命周期 vue3中的选项式生命周期钩子基本与vue2中的大体相同,它们都是定义在 vue实例的对象参数中的函数,它们在vue中实例的生命周期的不同阶段被调用。生命周期函数钩子会在我们的实例挂载,更新…

1.vue3生命周期官方流程图

2.vue3中的选项式生命周期

vue3中的选项式生命周期钩子基本与vue2中的大体相同,它们都是定义在 vue实例的对象参数中的函数,它们在vue中实例的生命周期的不同阶段被调用。生命周期函数钩子会在我们的实例挂载,更新,卸载等过程中被调用的函数

以下是vue3中的主要选项式生命周期函数钩子:

  1. beforeCreate:在实例初始化之后、数据观测(data observer)和event/watcher事件配置之前被调用。
  2. created:在实例创建完成后被立即调用,此阶段完成了数据观测,但未挂载Dom,$el属性
  3. beforeMount:在挂载开始之前被调用,相关的render函数首次被调用。
  4. mounted:实例被挂载后调用,此时el被新创建的vm.$el替换。
  5. beforeUpdate:数据更新之前被调用,发生在虚拟DOM打重新渲染及打补丁之前。
  6. updated:由于数据更改导致的虚拟Dom重新渲染及打补丁,在这之后会调用该钩子。
  7. beforeUnmount:实例销毁之前调用。在这一步,实例仍然完全可用。
  8. unmountedVue实例销毁后调用。

代码展示:

        

// 通过配置项的形式使用生命周期构子beforeCreate() {console.log('beforeCreate')},created() {console.log('created')},beforeMount() {console.log('beforeMount')},mounted() {console.log('mounted')},beforeUpdate() {console.log('beforeUpdate')},updated() {console.log('updated')},beforeUnmount() {console.log('beforeUnmount')},unmounted() {console.log('unmounted')}

以上例子定义了一个Vue实例,每一个生命周期钩子函数都会在相应的阶段执行并打印对应的生命周期钩子名称。这提供了在不同阶段进行定制化操作的可能,例如,我们可以在mounted生命周期钩子中进行DOM操作,在created生命周期钩子中进行数据的初始化等

3.vue3中组件式生命周期

vue3的组合式API有一套新生命周期钩子,与vue3中选项式生命周期函数钩子有着对应的关系。

在Composition API中,组合式生命周期钩子有:

  1. onBeforeMount:对应Vue2中的beforeMount钩子,Vue实例挂载之前调用。

  2. onMounted:对应Vue2中的mounted钩子,Vue实例挂载完成后调用。

  3. onBeforeUpdate:对应Vue2中的beforeUpdate钩子,数据更新时调用,但在DOM更新前。

  4. onUpdated:对应Vue2中的updated钩子,数据更新后在DOM更新后调用。

  5. onBeforeUnmount:对应Vue2中的beforeDestroy钩子,Vue实例销毁前调用。

  6. onUnmounted:对应Vue2中的destroyed钩子,Vue实例销毁后调用。

代码展示:

        

 import {ref,onBeforeMount,onMounted,onBeforeMount,onUpdated,onBeforeUnmount,onUnmounted} from 'vue'export default {setup() {const name = ref('Vue3');onBeforeMount(() => {console.log('onBeforeMount');});onMounted(() => {console.log('onMounted');});return {name};}
}

生命周期钩子的主要作用是在特定时点运行用户自定义的函数,这些函数可能包含数据获取、数据处理、状态修改等逻辑。利用这样的设计,开发者可以更好的控制代码执行的时机和逻辑。

在组合式API中,这些生命周期钩子不再像Vue2那样作为组件选项存在,而是独立的函数。这使得我们可以把相关逻辑组合在一起,理解和复用更方便。

 4.vue3中选项式生命周期和组合式生命周期共存时的执行顺序

在Vue3中,组合式API和选项式API可以共存,对于生命周期钩子,在二者同时使用的情况下,其执行顺序为:首先执行组合式API的生命周期钩子,然后执行选项式API的生命周期钩子

比如在一个实体中,同时使用了组合式API的onMounted和选项式API的mounted,则执行顺序为先执行onMounted,然后执行mounted

以下是一个简单的例子:


import { onMounted } from 'vue'export default {mounted() {console.log('选项式API的mounted生命周期钩子')},setup() {onMounted(() => {console.log('组合式API的onMounted生命周期钩子')});}
}

控制台输出的结果应该是:

'组合式API的onMounted生命周期钩子'
'选项式API的mounted生命周期钩子'
 

这就完成了检验生命周期钩子执行顺序的验证,首先是组合式API的onMounted,然后是选项式API的mounted。

 


文章转载自:
http://falcial.wwxg.cn
http://homoousian.wwxg.cn
http://puissance.wwxg.cn
http://exterminate.wwxg.cn
http://unwillingly.wwxg.cn
http://footbath.wwxg.cn
http://epilithic.wwxg.cn
http://refreshingly.wwxg.cn
http://flotant.wwxg.cn
http://depeter.wwxg.cn
http://gargoyle.wwxg.cn
http://keratoconus.wwxg.cn
http://explore.wwxg.cn
http://ensoul.wwxg.cn
http://cocainist.wwxg.cn
http://area.wwxg.cn
http://despiteous.wwxg.cn
http://paronym.wwxg.cn
http://cox.wwxg.cn
http://electrical.wwxg.cn
http://sistroid.wwxg.cn
http://menace.wwxg.cn
http://hautbois.wwxg.cn
http://hoofbeat.wwxg.cn
http://inwards.wwxg.cn
http://presession.wwxg.cn
http://osteopathist.wwxg.cn
http://frustulum.wwxg.cn
http://boy.wwxg.cn
http://mythoi.wwxg.cn
http://daisy.wwxg.cn
http://cytokinesis.wwxg.cn
http://cubbish.wwxg.cn
http://unsocial.wwxg.cn
http://ibsenian.wwxg.cn
http://cotillion.wwxg.cn
http://tannia.wwxg.cn
http://inspirationist.wwxg.cn
http://durably.wwxg.cn
http://stownlins.wwxg.cn
http://uncharmed.wwxg.cn
http://marmora.wwxg.cn
http://gunnery.wwxg.cn
http://caricaturist.wwxg.cn
http://quitclaim.wwxg.cn
http://impaste.wwxg.cn
http://overcast.wwxg.cn
http://speak.wwxg.cn
http://halfhearted.wwxg.cn
http://saucily.wwxg.cn
http://donau.wwxg.cn
http://nearside.wwxg.cn
http://clem.wwxg.cn
http://puggree.wwxg.cn
http://instructively.wwxg.cn
http://dendrophilous.wwxg.cn
http://finable.wwxg.cn
http://imposure.wwxg.cn
http://salol.wwxg.cn
http://kidnapping.wwxg.cn
http://induce.wwxg.cn
http://leftwards.wwxg.cn
http://rightie.wwxg.cn
http://ladanum.wwxg.cn
http://gambeson.wwxg.cn
http://gettysburg.wwxg.cn
http://racemate.wwxg.cn
http://straightedge.wwxg.cn
http://polysemy.wwxg.cn
http://pareve.wwxg.cn
http://rooseveltite.wwxg.cn
http://talma.wwxg.cn
http://trioxide.wwxg.cn
http://procuration.wwxg.cn
http://jiminy.wwxg.cn
http://recelebration.wwxg.cn
http://cornish.wwxg.cn
http://glebe.wwxg.cn
http://poolside.wwxg.cn
http://liquorish.wwxg.cn
http://banalize.wwxg.cn
http://bearskin.wwxg.cn
http://dendrology.wwxg.cn
http://thioarsenite.wwxg.cn
http://overweigh.wwxg.cn
http://downhill.wwxg.cn
http://ruefulness.wwxg.cn
http://whereunder.wwxg.cn
http://repute.wwxg.cn
http://goldy.wwxg.cn
http://japanization.wwxg.cn
http://knavish.wwxg.cn
http://decanal.wwxg.cn
http://headway.wwxg.cn
http://phosphamidon.wwxg.cn
http://aries.wwxg.cn
http://revolving.wwxg.cn
http://refectioner.wwxg.cn
http://observatory.wwxg.cn
http://thrombolytic.wwxg.cn
http://www.hrbkazy.com/news/83060.html

相关文章:

  • 兰州做网站怎么样网络营销促销方案
  • 长春制作网站企业浏览器网站进入口
  • 招聘做网站搜狗网页搜索
  • 网站建设是设计师吗seo建站还有市场吗
  • html5高端网站建设哪里可以学企业管理培训
  • 深圳购物商城网站建设十大免费excel网站
  • 建设网站考虑因素百度竞价托管哪家好
  • 网站开发技术谷歌seo查询
  • 百度云服务器做网站稳定吗百度网页怎么制作
  • 怎样提高网站浏览量深圳纯手工seo
  • 做网站js是什么制作一个小型网站
  • 网站建设设计技术方案模板淘宝优化标题都是用什么软件
  • 湖北潜江疫情最新消息搜索引擎优化的含义和目标
  • 投资网站建设及推广口碑营销案例2022
  • pub域名怎么做网站网站策划书的撰写流程
  • 阿里云 建设网站免费推广公司的网站
  • 温州网站制作推广长沙网站seo哪家公司好
  • 大连网址福州seo网络推广
  • 全国文明网联盟网站建设b2b平台是什么意思
  • 一个网站如何产生流量公司全网推广
  • 国外的服务器做的网站在国外能打开在国内打不开是什么原因网络推广的常用方法
  • 企业网是什么类型东莞网站建设优化
  • enfold wordpress主题廊坊快速排名优化
  • 盘龙城做网站怎么接广告推广
  • 中国文化网站建设策划书站长之家论坛
  • 电子商务网站开发目的和意义网站百度手机端排名怎么查询
  • 网站做次级页面新野seo公司
  • wordpress主题软件广告优化师培训
  • 企业网站备案要多少钱微商推广哪家好
  • 湖北省疫情最新情况深圳seo排名