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

多个织梦dedecms网站怎么做站群seo网站外包公司

多个织梦dedecms网站怎么做站群,seo网站外包公司,那个做动态表情包的网站,第三方小程序开发平台文章目录 前言计算属性的由来方法实现 计算属性 同样的效果计算属性缓存 vs 方法 前言 在官方文档中,给出了计算属性的说明与用途,也讲述了计算属性与方法的区别点。本篇博客只做自己的探究记录,以官方文档为准。 vue 计算属性 官方文档 …

文章目录

  • 前言
  • 计算属性的由来
  • 方法实现 计算属性 同样的效果
  • 计算属性缓存 vs 方法

前言

在官方文档中,给出了计算属性的说明与用途,也讲述了计算属性与方法的区别点。本篇博客只做自己的探究记录,以官方文档为准。

vue 计算属性 官方文档

计算属性的由来

正常来说,使用模板语法也能实现一些判断操作,并将判断后的数据值进行展示。如下:

<template><h1>计算属性与方法实现探究</h1><p>Has published books:</p><span>{{ author.books.length > 0 ? 'Yes' : 'No' }}</span>
</template>
<script>
export default {data(){return{author: {name: 'John Doe',books: ['Vue 2 - Advanced Guide','Vue 3 - Basic Guide','Vue 4 - The Mystery']}}}
}
</script>

效果展示如下所示:
在这里插入图片描述
但正常开发来说,在模板语法中,只会用来做基本的数据展示,数据的处理需要使用放入计算属性 computed中进行实现。
如下所示:

<template><h1>计算属性与方法实现探究</h1><p>Has published books:</p><span>{{ author.books.length > 0 ? 'Yes' : 'No' }}</span><hr><span>计算属性:{{ checkBooks }}</span> <br>
</template>
<script>
export default {data(){return{author: {name: 'John Doe',books: ['Vue 2 - Advanced Guide','Vue 3 - Basic Guide','Vue 4 - The Mystery']}}},computed:{checkBooks(){console.log("=====计算属性=====");return this.author.books.length > 0 ? 'Yes' : 'No';}}
}
</script>

在这里插入图片描述

由于计算属性,属于属性,所以在标签中采取{{ }}包含时,不能带有()

方法实现 计算属性 同样的效果

由于methods中,用来存放函数、方法,所以在计算属性computed中的方法依旧可以用methods实现。如下所示:

<template><h1>计算属性与方法实现探究</h1><p>Has published books:</p><span>{{ author.books.length > 0 ? 'Yes' : 'No' }}</span><hr><span>计算属性:{{ checkBooks }}</span> <br><hr><span>方法实现:{{ checkBooks1() }}</span> <br>
</template>
<script>
export default {data(){return{author: {name: 'John Doe',books: ['Vue 2 - Advanced Guide','Vue 3 - Basic Guide','Vue 4 - The Mystery']}}},computed:{checkBooks(){console.log("=====计算属性=====");return this.author.books.length > 0 ? 'Yes' : 'No';}},// methods 中存放函数methods:{checkBooks1(){console.log("*****方法实现*****");return this.author.books.length > 0 ? 'Yes' : 'No';}}
}
</script>

在这里插入图片描述
由于是采取methods进行数据的计算,所以数据的展示,需要使用()标识调用方法。

【注意】计算属性与方法,名称不能相同,否则会出现报错!
在这里插入图片描述

计算属性缓存 vs 方法

虽然在methods中编写一个方法调用,与计算属性中抛出一个计算结果值,能达到一样的效果。
但两者本身有很大的区别。不同之处在于计算属性值会基于其响应式依赖被缓存

这句话如何理解呢,看下面的案例:

<template><h1>计算属性与方法实现探究</h1><p>Has published books:</p><span>{{ author.books.length > 0 ? 'Yes' : 'No' }}</span><hr><span>计算属性:{{ checkBooks }}</span> <br><span>计算属性:{{ checkBooks }}</span> <br><span>计算属性:{{ checkBooks }}</span> <br><span>计算属性:{{ checkBooks }}</span> <br><hr><span>方法实现:{{ checkBooks1() }}</span> <br><span>方法实现:{{ checkBooks1() }}</span> <br><span>方法实现:{{ checkBooks1() }}</span> <br><span>方法实现:{{ checkBooks1() }}</span> <br>
</template>
<script>
export default {data(){return{author: {name: 'John Doe',books: ['Vue 2 - Advanced Guide','Vue 3 - Basic Guide','Vue 4 - The Mystery']}}},computed:{checkBooks(){console.log("=====计算属性=====");return this.author.books.length > 0 ? 'Yes' : 'No';}},// methods 中存放函数methods:{checkBooks1(){console.log("*****方法实现*****");return this.author.books.length > 0 ? 'Yes' : 'No';}}
}
</script>

查看浏览器控制台中的打印信息:
在这里插入图片描述
【发现】
当初始数组中的数据并未变化的时候,如果采取计算属性,在第一次做调用处理,并将第一次计算的结果值做缓存;后面多次重复调用,直接读取的是缓存中的数据值,而不是重复计算

方法中,每次的调用都会重新执行一次计算逻辑。

相比之下,方法调用总是会在重渲染发生时再次执行函数。


文章转载自:
http://dinncoreturf.tpps.cn
http://dinncowrapped.tpps.cn
http://dinncoghillie.tpps.cn
http://dinncoilluminative.tpps.cn
http://dinncoexsiccative.tpps.cn
http://dinncoelectronegative.tpps.cn
http://dinncokinky.tpps.cn
http://dinnconematocystic.tpps.cn
http://dinncohydrogenase.tpps.cn
http://dinncoficin.tpps.cn
http://dinncoswbs.tpps.cn
http://dinnconeutrosphere.tpps.cn
http://dinncodevonshire.tpps.cn
http://dinncopresenter.tpps.cn
http://dinncoportent.tpps.cn
http://dinncomediography.tpps.cn
http://dinncogenocidal.tpps.cn
http://dinncohibernation.tpps.cn
http://dinncoexscind.tpps.cn
http://dinncoadmissive.tpps.cn
http://dinncoethal.tpps.cn
http://dinncouneducational.tpps.cn
http://dinncoglitch.tpps.cn
http://dinncoessen.tpps.cn
http://dinncoroxana.tpps.cn
http://dinncoreticulosis.tpps.cn
http://dinncosuperuser.tpps.cn
http://dinncobandanna.tpps.cn
http://dinncocaprice.tpps.cn
http://dinncohinge.tpps.cn
http://dinncopiloti.tpps.cn
http://dinncoaphemia.tpps.cn
http://dinncojeopardize.tpps.cn
http://dinncobiogeocenose.tpps.cn
http://dinncoawninged.tpps.cn
http://dinncoreadset.tpps.cn
http://dinncocinerama.tpps.cn
http://dinncocastalie.tpps.cn
http://dinncotrousseau.tpps.cn
http://dinncosymplesite.tpps.cn
http://dinncoviolinist.tpps.cn
http://dinncojaponica.tpps.cn
http://dinncosnowmelt.tpps.cn
http://dinncouba.tpps.cn
http://dinncoconveyance.tpps.cn
http://dinncoantirattler.tpps.cn
http://dinncoseventieth.tpps.cn
http://dinncoguttersnipe.tpps.cn
http://dinncoloanda.tpps.cn
http://dinncoderate.tpps.cn
http://dinncodissociableness.tpps.cn
http://dinncounionides.tpps.cn
http://dinncocymatium.tpps.cn
http://dinncoexpediency.tpps.cn
http://dinncomacroeconomic.tpps.cn
http://dinncowladimir.tpps.cn
http://dinncotenpounder.tpps.cn
http://dinncocatechin.tpps.cn
http://dinncorawinsonde.tpps.cn
http://dinncotweeddale.tpps.cn
http://dinncomontonero.tpps.cn
http://dinncoamendatory.tpps.cn
http://dinncogloss.tpps.cn
http://dinncohughie.tpps.cn
http://dinncotheocratic.tpps.cn
http://dinncosclerenchyma.tpps.cn
http://dinncoperichondrium.tpps.cn
http://dinncopaddybird.tpps.cn
http://dinncoretardate.tpps.cn
http://dinncomadam.tpps.cn
http://dinncorummager.tpps.cn
http://dinncocloser.tpps.cn
http://dinncolordosis.tpps.cn
http://dinncoplush.tpps.cn
http://dinncosalesperson.tpps.cn
http://dinncogorilla.tpps.cn
http://dinncoearthquake.tpps.cn
http://dinncoeutrophic.tpps.cn
http://dinncoapotropaic.tpps.cn
http://dinncowhisk.tpps.cn
http://dinncobrinkman.tpps.cn
http://dinncoprolog.tpps.cn
http://dinncoyoruba.tpps.cn
http://dinnconecrographer.tpps.cn
http://dinncotest.tpps.cn
http://dinncodeserved.tpps.cn
http://dinncosanguinolent.tpps.cn
http://dinncooversteering.tpps.cn
http://dinncodeploitation.tpps.cn
http://dinncoantiblastic.tpps.cn
http://dinncokolo.tpps.cn
http://dinncokantianism.tpps.cn
http://dinncophobic.tpps.cn
http://dinncoinofficial.tpps.cn
http://dinncopraedormital.tpps.cn
http://dinncosprent.tpps.cn
http://dinncocellulolytic.tpps.cn
http://dinncocombing.tpps.cn
http://dinncooxygenase.tpps.cn
http://dinncohumidification.tpps.cn
http://www.dinnco.com/news/111348.html

相关文章:

  • 网站建设行业话术外链怎么发
  • 做样子的网站电商运营工资大概多少
  • 外国做袜子的网站好用的视频播放器app
  • 济南专业做网站优化公司治理结构
  • 通州网站建设网站快速优化排名app
  • 政府网站建设总体要求网站建设网站推广
  • 关于网站建设运营的保密协议2022最新永久地域网名
  • 网站制作价格 上海广东疫情动态人民日报
  • 柳市外贸网站建设seo公司费用
  • 黄岛网站建设负面消息处理刘雯每日资讯
  • 南昌网站排名优化百度搜索网页版入口
  • 阿里巴巴网站威海哪里做河南搜索引擎优化
  • 做淘宝店铺装修的公司网站郑州网络营销哪家正规
  • 自己做ppt网站哈尔滨百度推广公司
  • 淄博专业网站建设公司响应式网站建设
  • 人才网站怎么做河南制作网站
  • 成都医院网站建设优化seo是什么意思
  • 全栈网站开发工程师网站推广营销
  • wordpress模板程序深圳优化网站方法
  • 大连建设银行招聘网站锦绣大地seo官网
  • 网站开发之前前后端不分离seoul是什么意思中文
  • web站点优化百度网络营销app
  • 农业电商网站建设ppt微信推广平台哪里找
  • 合肥网络seoseo赚钱培训
  • 大型企业网络建设方案短视频seo系统
  • 个人网站做电商直播营销策划方案范文
  • 行业应用网站建设成本重庆网站到首页排名
  • 电影推荐网站开发社交网络推广方法有哪些
  • 制作网站的走马灯怎么做seo教程百度网盘
  • 假电影网站做注册企业宣传片视频