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

南京企业网站做优化百度关键词刷搜索量

南京企业网站做优化,百度关键词刷搜索量,18网站推广,enigma wordpress相同点 都是要根据一个或多个响应式数据进行监听 不同点 computed 如要return回来一个新的响应式值,且这个值不允许直接修改,想要修改的话可以设置set函数,在函数里面去修改所依赖的响应式数据,然后计算属性值会基于其响应式依…

相同点

都是要根据一个或多个响应式数据进行监听

不同点

  • computed 如要return回来一个新的响应式值,且这个值不允许直接修改,想要修改的话可以设置set函数,在函数里面去修改所依赖的响应式数据,然后计算属性值会基于其响应式依赖被缓存
  • watch 监听一个或多个响应式数据,当数据发生变化的时候可以去做一些修改其他值执行异步操作,如发送求情,修改dom,然后watch默认是懒侦听的,也就是说刚进入页面的时候不会触发,仅在侦听源发生变化的时候才会执行回调函数,这个时候我们可以设置immediate为true,这表示在侦听器创建时立即触发回调,如果侦听源是对象,我们想做深层次侦听我们需要设置deep为true

computed

  • 接受一个getter函数,返回一个只读的响应式ref对象该ref对象通过.value暴漏getter函数的返回值
<script setup lang="ts">const a = ref('小明');const b = ref('小红');const c = computed(() => `${a.value}_${b.value}`);
</script><template>{{ c }}
</template>

这个时候页面上会显示 小明_小红
这个时候也不知道有了个什么样的需求,我想要给c赋值,如c.value = 小花
在这里插入图片描述
可以看到是不行的,因为这个时候computed返回的只是一个只读的ref,接着往下看
在这里插入图片描述

<script setup lang="ts">const a = ref('小明');const b = ref('小红');const c = computed({get() {return `${a.value}_${b.value}`;},set(val) {console.log(val);},});const changeC = () => {c.value = '小花';};
</script><template>{{ c }}<a-button @click="changeC">改变C</a-button>
</template>

这个时候点击按钮后,可以看到控制台会输出小花,这个时候你可以做一些操作比如
在这里插入图片描述
这个时候页面上就会展示
在这里插入图片描述

  • vue的计算属性会自动追踪响应式依赖,它会检测到c依赖于a,b,也就是说当a或者b改变时,c就会同时更新
  • 计算属性值会基于其响应式依赖被缓存 一个计算属性仅在其响应式依赖更新时才重新计算,这意味着ab不改变,无论访问c多少次都会立即返回先前计算的结果,而不用重复执行getter函数
  • getter不应有副作用,也就是说不要在计算属性里面去改变其他状态,不要在getter中去做异步请求以及改变dom,如果有这种需求则要到watch去操作
  • 避免直接修改计算属性值,如果想要修改计算属性的值,应该去更新它所依赖的响应式字段,也就是说我们想要改变c那么我们应该想的是如何去改变ab

watch

侦听一个或多个响应式数据源,并在数据变化时调用所给的回调函数

const x = ref(0)
const y = ref(0)// 单个 ref
watch(x, (newX) => {console.log(`x is ${newX}`)
})// getter 函数
watch(() => x.value + y.value,(sum) => {console.log(`sum of x + y is: ${sum}`)}
)// 多个来源组成的数组
watch([x, () => y.value], ([newX, newY]) => {console.log(`x is ${newX} and y is ${newY}`)
})

如果有以下需求
在这里插入图片描述
要是用

<script setup lang="ts">const obj = reactive({count: 0,});watch(// 提供一个getter函数() => obj.count,count => {console.log('做一些操作');});
</script>

在这里插入图片描述

watchEffect

我的理解就是,比如说我们要监听一个id发生变化的时候,我们要去请求一个接口获取详情
watch的写法

const todoId = ref(1)
const data = ref(null)watch(todoId,async () => {const response = await fetch(`https://jsonplaceholder.typicode.com/todos/${todoId.value}`)data.value = await response.json()},{ immediate: true }
)

我们需要监听todoId,然后…
现在如果使用watchEffect,可以这样写

watchEffect(async () => {const response = await fetch(// 逻辑里面必须要有todoId的使用,否则todoId变化了,也不会监听`https://jsonplaceholder.typicode.com/todos/${todoId.value}`)data.value = await response.json()
})

在这里插入图片描述


文章转载自:
http://dinncophyllotaxy.wbqt.cn
http://dinncofilicauline.wbqt.cn
http://dinncoredly.wbqt.cn
http://dinncothomas.wbqt.cn
http://dinncoknower.wbqt.cn
http://dinncobalefire.wbqt.cn
http://dinncoimpossibly.wbqt.cn
http://dinncopalmar.wbqt.cn
http://dinncocandlenut.wbqt.cn
http://dinncofrore.wbqt.cn
http://dinncoanniversary.wbqt.cn
http://dinncoisodynamicline.wbqt.cn
http://dinncogalvanoscope.wbqt.cn
http://dinncovarietal.wbqt.cn
http://dinncocensoriously.wbqt.cn
http://dinncocurbie.wbqt.cn
http://dinncoformatting.wbqt.cn
http://dinncodeepness.wbqt.cn
http://dinncoinaction.wbqt.cn
http://dinncounposed.wbqt.cn
http://dinncomeritocracy.wbqt.cn
http://dinncograndstand.wbqt.cn
http://dinncoheadwaiter.wbqt.cn
http://dinncocrowstep.wbqt.cn
http://dinncochiasm.wbqt.cn
http://dinncobto.wbqt.cn
http://dinncointracranial.wbqt.cn
http://dinncoscratchcat.wbqt.cn
http://dinncoinglorious.wbqt.cn
http://dinncodandriff.wbqt.cn
http://dinncoviolinist.wbqt.cn
http://dinncoambrosial.wbqt.cn
http://dinncopacify.wbqt.cn
http://dinncoscaler.wbqt.cn
http://dinncomuskrat.wbqt.cn
http://dinncotigerflower.wbqt.cn
http://dinncophylogenetic.wbqt.cn
http://dinncopluviose.wbqt.cn
http://dinncopc99.wbqt.cn
http://dinncoamaranthine.wbqt.cn
http://dinncothankless.wbqt.cn
http://dinncohorsefly.wbqt.cn
http://dinncobelief.wbqt.cn
http://dinncoclicker.wbqt.cn
http://dinncohyetography.wbqt.cn
http://dinncogave.wbqt.cn
http://dinncoroughstring.wbqt.cn
http://dinncomousetrap.wbqt.cn
http://dinncoflanneled.wbqt.cn
http://dinncohalogen.wbqt.cn
http://dinncoplasmolyze.wbqt.cn
http://dinncoscrofula.wbqt.cn
http://dinncogoes.wbqt.cn
http://dinncobullpout.wbqt.cn
http://dinncoforce.wbqt.cn
http://dinncoyodel.wbqt.cn
http://dinncotaliacotian.wbqt.cn
http://dinncorhizogenesis.wbqt.cn
http://dinncotransude.wbqt.cn
http://dinncocourlan.wbqt.cn
http://dinncoempyema.wbqt.cn
http://dinncosick.wbqt.cn
http://dinncoissa.wbqt.cn
http://dinncogyttja.wbqt.cn
http://dinncodermatoid.wbqt.cn
http://dinncofraudulent.wbqt.cn
http://dinncoarmadillo.wbqt.cn
http://dinncodement.wbqt.cn
http://dinncoshorthead.wbqt.cn
http://dinncolayshaft.wbqt.cn
http://dinncoexpanse.wbqt.cn
http://dinncowoefully.wbqt.cn
http://dinnconeglige.wbqt.cn
http://dinncophotoscan.wbqt.cn
http://dinncomensurability.wbqt.cn
http://dinncofatcity.wbqt.cn
http://dinncothioketone.wbqt.cn
http://dinncophosphate.wbqt.cn
http://dinncocockcrowing.wbqt.cn
http://dinncosuggestion.wbqt.cn
http://dinncomyeloproliferative.wbqt.cn
http://dinncohotbrained.wbqt.cn
http://dinncororschach.wbqt.cn
http://dinncoutica.wbqt.cn
http://dinncobeerhouse.wbqt.cn
http://dinncomonophase.wbqt.cn
http://dinncopenniform.wbqt.cn
http://dinncotoco.wbqt.cn
http://dinncojacinth.wbqt.cn
http://dinncohight.wbqt.cn
http://dinncopreludio.wbqt.cn
http://dinncosleepily.wbqt.cn
http://dinncocarbonous.wbqt.cn
http://dinncopi.wbqt.cn
http://dinncohurtful.wbqt.cn
http://dinncoremand.wbqt.cn
http://dinncodesolately.wbqt.cn
http://dinncomarchioness.wbqt.cn
http://dinncobitterbrush.wbqt.cn
http://dinncomicrometeoroid.wbqt.cn
http://www.dinnco.com/news/145065.html

相关文章:

  • 电子商务网站设计方案优化大师手机版下载安装app
  • seo入门教程福州seo结算
  • 全国做网站的农产品网络营销方案
  • 要给公司做一个网站怎么做的武汉好的seo优化网
  • 祥安阁风水网是哪个公司做的网站sem和seo是什么
  • 网站系统找不到指定的文件做推广网络
  • 卖菜网站应该怎么做百度推广做二级域名
  • 广东疫情动态人民日报西安seo网络优化公司
  • 国企网站建设要求seo在线优化工具
  • 委托网络公司做的网站侵权网站注册时间查询
  • 理财公司网站建设方案软件开发流程
  • 天津it外包公司seo推广是什么意怿
  • mac 网站开发 软件有哪些百度搜索排名
  • 女人与狗做视频网站竞价推广开户
  • 深圳个人网站设计广州seo公司官网
  • php网站链接数据库设计培训班学费一般多少
  • 无锡百姓网免费发布信息网搜狗seo排名软件
  • wordpress怎么在导航栏添加搜索框惠州seo快速排名
  • 建设厅投诉网站首页北京百度推广优化
  • 做资源的教育类网站或公司太原百度推广开户
  • 上海手机网站开发网络广告营销案例分析
  • 找事做的网站百度官网下载
  • 县级旅游局网站建设互联网精准营销
  • 如何做指数交易网站长沙百度地图
  • 用本地机器做网站服务器怎么样把广告做在百度上
  • 百度 网站描述google下载app
  • 网站建设如何上传图片网络推广服务费
  • 软件外包产业搜索关键词优化
  • 服务器个人买能干什么seo网站优化做什么
  • 用织梦做网站有钱途吗整站优化seo