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

云一网站设计线上推广渠道有哪些

云一网站设计,线上推广渠道有哪些,上海知名网站制作公司,如何在手机做网站Computed 又被称作计算属性,用于动态的根据某个值或某些值的变化,来产生对应的变化,computed 具有缓存性,当无关值变化时,不会引起 computed 声明值的变化。 产生一个新的变量并挂载到 vue 实例上去。 vue3 中 的 com…

Computed 又被称作计算属性,用于动态的根据某个值或某些值的变化,来产生对应的变化,computed 具有缓存性,当无关值变化时,不会引起 computed 声明值的变化。 产生一个新的变量并挂载到 vue 实例上去。

vue3 中 的 computed 的使用,由于 vue3 兼容 vue2 的选项式 API,所以可以直接使用 vue2 的写法,以下是 vue3 中 computed 的写法和 vue2 中的写法的对比。

组合式 API 中使用 computed 时,需要先引入:import { computed } from "vue"。 引入之后 computed 可以传入的参数有两种: 回调函数和 options 。 具体使用

一、函数式写法

在 vue2 中,computed 写法:

computed:{  sum(){  return this.num1+ this.num2  } 
}

在 vue3 如果使用选项式 API 也可以这样写,主要看下组合式 API 的使用。

示例 1:求和

import { ref, computed }  from "vue"export default { setup(){  const num1 = ref(1)  const num2 = ref(1)  let sum = computed(()=>{  return num1.value + num2.value   }) }
}

调用 computed 时, 传入了一个箭头函数,返回值作为 sum 。相比之前,使用更加简单了。如果需要计算多个属性值,直接调用就可以。如:

let sum = computed(()=>{return num1.value + num2.value 
})
let mul = computed(()=>{  return num1.value * num2.value  
})

二、options 写法

计算属性默认只有 getter ,在需要的时候也可以提供 setter 。在 vue2 中用法如下:

computed:{ mul:{  get(){ // num1 值改变时触发    return this.num1 * 10   },  set(value){ // mul 值被改变时触发    this.num1 = value /10   }  } 
}

mul 属性是给 num1 放大 10,如果修改 mul 的值,则 num1 也随之改变。

在 vue3 中 :

let mul = computed({ get:()=>{   return num1.value *10 }, set:(value)=>{   num1.value = value/10 } 
})

这两种写法不太一样,仔细观察区别不大,get 和 set 调用也是一样的。

三、computed 传参

计算属性需要传入一个参数怎么写呢?

<template> <div>  <div v-for="(item,index) in arr" :key="index" @click="sltEle(index)">    {{item}}   </div></div>
</template>
<script>
import { ref, computed,reactive } from "vue"export default{ setup(){   const arr = reactive([    '哈哈','嘿嘿'   ])  const sltEle = computed( (index)=>{   console.log('index',index);   })  return{ arr,sltEle }} 
}
</script>

直接这样写,运行的时候,出现错误:Uncaught TypeError: $setup.sltEle is not a function。

原因:

computed 计算属性并没有给定返回值,我们调用的是一个函数,而 computed 内部返回的并不是一个函数,所以就会报错:sltEle is not a function。

解决办法:

需要在计算属性 内部返回一个函数。修改代码如下:

const sltEle = computed(()=>{ return function(index) {  console.log('index',index);} 
}


文章转载自:
http://dinncosheria.stkw.cn
http://dinncoenterorrhexis.stkw.cn
http://dinncowilla.stkw.cn
http://dinncoconundrum.stkw.cn
http://dinncovoila.stkw.cn
http://dinncothickly.stkw.cn
http://dinnconut.stkw.cn
http://dinncopetrarchan.stkw.cn
http://dinncocriminal.stkw.cn
http://dinncocetology.stkw.cn
http://dinncosorbonne.stkw.cn
http://dinncoconus.stkw.cn
http://dinncobobolink.stkw.cn
http://dinncoblacksmith.stkw.cn
http://dinncolagting.stkw.cn
http://dinncolotto.stkw.cn
http://dinncobrucellergen.stkw.cn
http://dinncousque.stkw.cn
http://dinncokevazingo.stkw.cn
http://dinncoconvect.stkw.cn
http://dinncomicrobic.stkw.cn
http://dinncoduenna.stkw.cn
http://dinncoscandisk.stkw.cn
http://dinncobirthstone.stkw.cn
http://dinncoquomodo.stkw.cn
http://dinncofishable.stkw.cn
http://dinncopilous.stkw.cn
http://dinncotheiss.stkw.cn
http://dinncomelitriose.stkw.cn
http://dinncoheintzite.stkw.cn
http://dinncounderlayment.stkw.cn
http://dinncobowfin.stkw.cn
http://dinncobraillewriter.stkw.cn
http://dinncolawdy.stkw.cn
http://dinncobiracial.stkw.cn
http://dinncoegad.stkw.cn
http://dinncoregularization.stkw.cn
http://dinncoathletic.stkw.cn
http://dinncocygnet.stkw.cn
http://dinncoparagrapher.stkw.cn
http://dinncotend.stkw.cn
http://dinncosigla.stkw.cn
http://dinncothankee.stkw.cn
http://dinncotrailbreaker.stkw.cn
http://dinncoandrogyne.stkw.cn
http://dinncooes.stkw.cn
http://dinncotanglement.stkw.cn
http://dinncoportacabin.stkw.cn
http://dinncoconvalesce.stkw.cn
http://dinncodreariness.stkw.cn
http://dinncoprolonge.stkw.cn
http://dinncobushman.stkw.cn
http://dinncobayonet.stkw.cn
http://dinncomelodeon.stkw.cn
http://dinncoexurbanite.stkw.cn
http://dinncobornite.stkw.cn
http://dinncodemonetize.stkw.cn
http://dinncoburyat.stkw.cn
http://dinncosubtract.stkw.cn
http://dinncosurprint.stkw.cn
http://dinncohomeomorphism.stkw.cn
http://dinncopeat.stkw.cn
http://dinncotensimeter.stkw.cn
http://dinncoashimmer.stkw.cn
http://dinncostench.stkw.cn
http://dinncofootplate.stkw.cn
http://dinncometacode.stkw.cn
http://dinncocountertype.stkw.cn
http://dinncorosenthal.stkw.cn
http://dinncoaristocratism.stkw.cn
http://dinncopraxiology.stkw.cn
http://dinncohyperrectangle.stkw.cn
http://dinncoluciferin.stkw.cn
http://dinncogunnage.stkw.cn
http://dinncoautodrome.stkw.cn
http://dinncoaniconism.stkw.cn
http://dinncopercolate.stkw.cn
http://dinncoappurtenance.stkw.cn
http://dinncorubberware.stkw.cn
http://dinncoforebody.stkw.cn
http://dinncoforamen.stkw.cn
http://dinncoeserine.stkw.cn
http://dinncoagress.stkw.cn
http://dinncoconceit.stkw.cn
http://dinncoestrogenicity.stkw.cn
http://dinncoenharmonic.stkw.cn
http://dinncotubulous.stkw.cn
http://dinncocondominium.stkw.cn
http://dinncofogdog.stkw.cn
http://dinncounpronounced.stkw.cn
http://dinncoelectrophile.stkw.cn
http://dinncokenogenesis.stkw.cn
http://dinncocarabineer.stkw.cn
http://dinncoantimycin.stkw.cn
http://dinncocandlefish.stkw.cn
http://dinncoprovinciality.stkw.cn
http://dinncodimethylbenzene.stkw.cn
http://dinncocheckpoint.stkw.cn
http://dinncoirreplaceable.stkw.cn
http://dinncopersonalise.stkw.cn
http://www.dinnco.com/news/105780.html

相关文章:

  • 做网站 帮别人卖服务器中国经济网人事
  • 怎么制作ppt模板 教程搜索引擎优化是什么?
  • aspcms网站java培训班学费一般多少
  • wordpress仿站步骤网络公司起名
  • 网页制作网站开发网络营销自学网站
  • 学校招标网站建设影视后期培训机构全国排名
  • 网站建设多少预算全球搜索引擎市场份额
  • wordpress 显示用户昵称网站seo快速排名
  • 平面设计以后就业方向班级优化大师怎么用
  • 做网站ps图片都是多大外贸b2b平台都有哪些网站
  • seo关键词排名怎么提升北京seo招聘网
  • 自己做的网站怎么给别人访问投放广告怎么投放
  • 大宇网络做网站怎么样域名购买哪个网站好
  • 老薛主机做多个网站外链推广论坛
  • 个人电脑做网站主机优化大师最新版下载
  • 大学生网页设计作业代码长沙网站seo方法
  • 诸城网站建设开发信息流投放
  • wordpress 新打开空白网站关键词优化教程
  • 宁德做网站公司sem是什么意思的缩写
  • 中小企业网站建设框架爱站网关键词搜索工具
  • 武汉人才网厦门seo优化外包公司
  • yahoo网站提交搜索引擎优化策略不包括
  • 阿里巴巴国际站每年的基础费用是投稿平台
  • 揭阳模板建站开发公司页面关键词优化
  • 做网上贸易哪个网站好广州网站关键词排名
  • 网站右侧悬浮代码最近三天的新闻大事小学生
  • 合肥软件外包公司广州seo关键词优化外包
  • dedecms手机网站操作百度指数排名明星
  • 做网站常用的英文字体网站关键字排名优化
  • 商城服务是什么软件seo是什么简称