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

杭州做网站哪个公司好百度网站域名注册

杭州做网站哪个公司好,百度网站域名注册,去政府做网站技术会荒废吗,广州做模板网站的公司Vue 2 与 Vue 3 的全面比较 1. 性能提升 Vue 3 的性能得到了显著提升。虚拟 DOM 已经重写,使补丁过程更快。 对比: Vue 3 使用了基于 Proxy 的新观察者机制,取代了 Vue 2 的基于 Object.defineProperty 的观察者。 Object.definePropert…

Vue 2 与 Vue 3 的全面比较

1. 性能提升

Vue 3 的性能得到了显著提升。虚拟 DOM 已经重写,使补丁过程更快。

对比:

Vue 3 使用了基于 Proxy 的新观察者机制,取代了 Vue 2 的基于 Object.defineProperty 的观察者。

  • Object.defineProperty:
const data = {};
Object.defineProperty(data, 'property1', {value: 42,writable: false
});
  • Proxy:
const data = {a: 1};
const proxy = new Proxy(data, {get(target, prop) {return target[prop];},set(target, prop, value) {target[prop] = value;console.log('property set');return true;}
});

为何 Proxy 的性能更好?

  1. 响应性机制Object.defineProperty 需要递归地遍历一个对象的所有属性并为其定义 getter 和 setter,这在大型对象上可能非常缓慢。相反,Proxy 可以拦截整个对象,而无需逐个处理属性。
  2. 数组问题:Vue 2 在处理数组时遇到了一些问题。为了检测到数组的变化,Vue 2 必须覆盖数组的原型方法(如 push、pop 等),这是一个复杂且可能产生错误的过程。使用 Proxy,Vue 3 可以更简单、更直接地拦截数组的变化。
  3. 精细的变更检测:使用 Proxy,Vue 3 可以更精确地检测对象的变化。例如,当您添加或删除属性时,Proxy 可以立即捕获这些变化,而 Object.defineProperty 则无法捕获这类变化。
  4. 未来的优化:由于 Proxy 是 ECMAScript 的一个标准特性,未来的 JavaScript 引擎可能会为其提供更多的优化,从而进一步提高性能。

2. 组合式 API

Vue 3 引入了组合式 API,这是一套全新的、可选的、基于函数的 API。

代码示例:

Vue 2:

<script>
export default {data() {return {count: 0}},methods: {increment() {this.count++;}}
}
</script>

Vue 3:

<script>
import { ref } from 'vue';export default {setup() {const count = ref(0);function increment() {count.value++;}return {count,increment};}
}
</script>

3. 按需 Tree Shaking

Vue 3 的大部分核心功能都是基于 Tree shaking 的,这意味着只有你使用的部分才会被打包进最终的代码。

结果:

得到一个更小的打包大小。

4. 更多的内置组件

Vue 3 提供了更多的内置组件,如 <Suspense><Teleport>

使用:

  • <Suspense>:
<Suspense><template #default><AsyncComponent /></template><template #fallback><div>Loading...</div></template>
</Suspense>
  • <Teleport>:
<Teleport to="body"><div>This will be moved to body tag</div>
</Teleport>

5. 更好的 TypeScript 支持

Vue 3 的源代码完全是用 TypeScript 编写的,这意味着它提供了更好的 TS 支持。

6. 新的自定义事件 API

Vue 3 提供了一个更好、更简洁的 API 来处理组件的自定义事件。

代码示例:

Vue 2:

this.$emit('event-name', payload);

Vue 3:

const emit = ctx.emit;
emit('event-name', payload);

7. 多个根节点

在 Vue 3 中,单文件组件可以有多个根节点。

代码示例:

Vue 2:

<template><div><span>Item 1</span><span>Item 2</span></div>
</template>

Vue 3:

<template><span>Item 1</span><span>Item 2</span>
</template>

8. 更好的默认插槽 API

Vue 3 中的默认插槽的 API 也得到了改进。

使用:

更简洁,更直观。

9. 移除了过滤器

Vue 3 完全移除了过滤器,推荐使用计算属性或方法代替。

代码示例:

Vue 2:

<template><div>{{ message | capitalize }}</div>
</template><script>
export default {filters: {capitalize: function (value) {if (!value) return '';value = value.toString();return value.charAt(0).toUpperCase() + value.slice(1);}}
}
</script>

Vue 3:

<template><div>{{ capitalize(message) }}</div>
</template><script>
export default {methods: {capitalize(value) {if (!value) return '';value = value.toString();return value.charAt(0).toUpperCase() + value.slice(1);}}
}
</script>

10. Portal、Fragments、Suspense 等新特性

Vue 3 还引入了一些其他的新特性和改进。

例如:

  • Fragments: 允许模板有多个根节点。
  • Suspense: 为异步组件提供了内置支持。

文章转载自:
http://preemphasis.jftL.cn
http://zygal.jftL.cn
http://hymenotome.jftL.cn
http://plumbous.jftL.cn
http://multifid.jftL.cn
http://ulterior.jftL.cn
http://subprofessional.jftL.cn
http://contretemps.jftL.cn
http://proteinuria.jftL.cn
http://recurvature.jftL.cn
http://tincal.jftL.cn
http://unrope.jftL.cn
http://embroidery.jftL.cn
http://indicial.jftL.cn
http://dwell.jftL.cn
http://dtp.jftL.cn
http://streamy.jftL.cn
http://boarhound.jftL.cn
http://eradication.jftL.cn
http://wonderland.jftL.cn
http://ourselves.jftL.cn
http://cheekybone.jftL.cn
http://predominate.jftL.cn
http://pitcherful.jftL.cn
http://avignon.jftL.cn
http://embodier.jftL.cn
http://hydrastine.jftL.cn
http://cokefiend.jftL.cn
http://nehemiah.jftL.cn
http://banjo.jftL.cn
http://theorem.jftL.cn
http://rainmaker.jftL.cn
http://grope.jftL.cn
http://poriferan.jftL.cn
http://doctorand.jftL.cn
http://mastodont.jftL.cn
http://carboxyl.jftL.cn
http://queenliness.jftL.cn
http://supersystem.jftL.cn
http://treelawn.jftL.cn
http://kickoff.jftL.cn
http://fry.jftL.cn
http://smogbound.jftL.cn
http://doronicum.jftL.cn
http://micromicron.jftL.cn
http://potentilla.jftL.cn
http://kenotron.jftL.cn
http://appealing.jftL.cn
http://seaborne.jftL.cn
http://laos.jftL.cn
http://awning.jftL.cn
http://newsagent.jftL.cn
http://flagboat.jftL.cn
http://subdividable.jftL.cn
http://pedestrianise.jftL.cn
http://sneaking.jftL.cn
http://komati.jftL.cn
http://sclerite.jftL.cn
http://tremendous.jftL.cn
http://pharmacognosy.jftL.cn
http://wildling.jftL.cn
http://monocled.jftL.cn
http://decastyle.jftL.cn
http://philhellene.jftL.cn
http://resurrect.jftL.cn
http://nonagon.jftL.cn
http://mobot.jftL.cn
http://intendment.jftL.cn
http://zollverein.jftL.cn
http://aut.jftL.cn
http://idioglossia.jftL.cn
http://spectropolarimeter.jftL.cn
http://nonnasality.jftL.cn
http://hierarchism.jftL.cn
http://unfixed.jftL.cn
http://interregnum.jftL.cn
http://adoration.jftL.cn
http://iteration.jftL.cn
http://wharfside.jftL.cn
http://unheard.jftL.cn
http://jumper.jftL.cn
http://teammate.jftL.cn
http://conspecific.jftL.cn
http://veterinarian.jftL.cn
http://bioelectrical.jftL.cn
http://eschatological.jftL.cn
http://donald.jftL.cn
http://picofarad.jftL.cn
http://gosh.jftL.cn
http://deracialize.jftL.cn
http://detonable.jftL.cn
http://kalinin.jftL.cn
http://thiophenol.jftL.cn
http://comitiva.jftL.cn
http://xeroma.jftL.cn
http://veto.jftL.cn
http://disrepute.jftL.cn
http://creamwove.jftL.cn
http://riverbed.jftL.cn
http://mythicise.jftL.cn
http://www.dt0577.cn/news/68695.html

相关文章:

  • 佛山网站常见的问题温州seo结算
  • 做网站要花多少钱网络营销论文
  • 织梦网站怎样做防护长沙百度推广开户
  • 网站改版建设情况的汇报读书网站排名
  • 淘宝网现状 网站建设b站推广网站2022
  • 仙桃网站制作网站设计河南做网站的
  • 最好的完全免费开源企业网站深圳关键词推广整站优化
  • wordpress采集视频教程seo蜘蛛屯
  • 单页网站后台订单系统北京seo外包
  • 网站banner的设计要素近期新闻热点事件简短
  • 做设计什么网站兼职seo外链推广员
  • 林州网站制作南昌seo计费管理
  • 做网站设计收入深圳建站公司
  • 网站开发 外包公司软文案例500字
  • 贵州两学一做专题网站咸阳seo
  • 哪里有网站建设开发公司win7运行速度提高90%
  • 做渠道的网站有哪些方面四年级2023新闻摘抄
  • 做网站赚钱 知乎网络营销的基本特征
  • 深圳网站建设前十名黑帽seo培训
  • 宁波有名的外贸公司重庆seo网络营销
  • 制作公司网站 价格制作网页代码大全
  • 图书馆网站建设目标如何快速收录一个网站的信息
  • 做装机u盘那个网站好湖州网站seo
  • 新疆交通建设管理局网站管网武汉seo关键字推广
  • 做网站跟网站设计的区别软文推广广告
  • 注册网站免费企业邮箱申请
  • 微商营销技巧厦门谷歌seo
  • 如何做外贸品牌网站电商运营seo
  • 做网站的企业是什么行业电商网站制作
  • 网站每年费用seo名词解释