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

wordpress多站点开启竞价推广平台有哪些

wordpress多站点开启,竞价推广平台有哪些,太原网站建设随州,光谷做网站推广ref、reactive是在 setup() 声明组件内部状态用的&#xff0c; 这些变量通常都要 return 出去&#xff0c;除了供 < template > 或渲染函数渲染视图&#xff0c;也可以作为 props 或 emit 参数 在组件间传递。它们的值变更可触发页面渲染。 ref &#xff1a;是一个函数&…

ref、reactive是在 setup() 声明组件内部状态用的, 这些变量通常都要 return 出去,除了供 < template > 或渲染函数渲染视图,也可以作为 props 或 emit 参数 在组件间传递。它们的值变更可触发页面渲染。

ref :是一个函数,用于创建一个响应式的引用,通俗的说就是把一个变量转变成响应式变量。定义基本类型数据(支持所有的类型).能指定基础类型和复杂类型. 也可以读取dom(详见实例1)

isRef: 是判断一个对象是否是Ref 类型。

Ref :是 TypeScript 中的类型,用于描述由 ref 创建的响应式对象的类型。
import type {Ref} from ‘vue’
const count: Ref = ref(0);

reacive:和ref功能相同,但是使用范围不同。只能指定基础类型(引用类型), 定义对象(或数组)类型(引用类型) Array,Object,Map,Set。 其次ref 取值或者修改值需要用到value, 而reactive则不需要。reacive 不能直接赋值,否则就会破坏其响应式, readonly可以将其属性转化为只读。其次shallowReactive也是浅层响应。 详见实例4

shallowRef : 用于浅层响应式的。ref 可以做深层次相应的。但是在同一个方法中,二者不可以同时使用,否则shallowRef 就会失去浅层相应。 二者的底层都是triggerRef,所有被强制执行了。

triggerRef: 强制更新页面DOM,一般情况下不直接使用。

customRef :顾名思义,就是可以自定义ref函数。接受一个工厂函数作为参数,这个工厂函数返回一个对象,该对象需要实现 get 和 set 方法。 一般情况下用不到,属于高级编程。 详见实例2

toRefs: 使从reactive定义的解构数据变成响应式的。用于将整个 reactive 对象中的每个属性转换为 ref,适合解构赋值的场景。

toRef:用于将 reactive 对象中的单个属性转换为 ref,适合只处理某个特定属性的场景。是对传入对象指定属性的响应式绑定,值改变不会更新视图。只能修改响应式对象的值,非响应式视图毫无变化。该函数需要两个参数,第一个是对象,第二个是对象的属性。

它们的主要区别在于作用的范围:toRefs 处理所有属性,而 toRef 仅处理单个属性

toRaw: 用于获取响应式对象的原始数据对象,不受响应式系统的影响。就是解除响应式。
左侧是: man对象,右侧是 toRaw(man)
在这里插入图片描述

我们可以自己编写一下toRefs的功能:

const man = reactive({name:'lvmanba', age:50, like: 'eat'})
const toRefs = <T extends object>(object:T) =>{const map:any = {}for(let key in object){map[key] = toRef(object,key)}return map
}const {name,age,like} = toRefs(man)

toRef、toRefs 用于处理 组件/函数 传递的响应式数据,如:在接收父组件 props 时 / 或 composables 组合式函数返回数据时建立起某些属性的响应式引用;
通过 ref 包装的属性在 setup 函数内都需要通过 .value 去访问它值 ( template 模版内不用 )。因此,ref、toRef 创建的变量值都需要用变量 .value 读取。reactive 则不用,因为会自动解包分配给它的 ref。
至于 toRefs,如果是解构赋值,如: const { state1, state2 } = toRefs(props),值需要这样获取:state1.value.count;
若整体赋给一个变量,如:const state = toRefs(props),则是 state.state1.value。
只有 toRefs 可以解构;

实例1

<template><div>{{Man}}</div><div>{{Man2}}</div><button @click="change">修改</button>
</template>
<script setup lang='ts'>
import { ref,reactive, shallowRef,triggerRef, customRef } from 'vue'
import type {Ref} from 'vue'
//const Man = {name: "lvmanba"}  //下面将无法修改
type M = {name: string
}
//可以使用两种方式,第一种(Ref)如果类型比较复杂,则推荐使用。一般使用第二种。
//第一种:
//const Man:Ref<M> = ref({name:"lvmanba"})
//第二种:
//const Man = ref<M>({name:"lvmanba"})   //ref<泛型类型>({对象})
//第三种:
const Man = ref({name:"lvmanba1"})   //让自己判断类型
const Man2 = shallowRef({name:"lvmanba2"})  //应该是浅层相应,只能到value。
const change = () =>{// ref 返回的是ES6的class类,通过它里面的属性value来获取值。 固定语法//Man.value.name = "lvmanba1-1"//Man2.value.name = "lvmanba2-1"//注意,如果同时在一个方法中修改ref和shallowRef两种类型,则shallowRef失效。 修改shallowRef类型的值有两种方法。//方法1:Man2.value.name = "lvmanba2-1"triggerRef(Man2)//方法2:/*Man2.value = {name:"我被修改了"}*/console.log(Man)
}
</script>
<style scoped></style>

实例2: 自定义ref

<template><div>{{Man}}</div><button @click="change">修改</button>
</template>
<script setup lang='ts'>
import { ref,reactive, shallowRef,triggerRef, customRef} from 'vue'
function MyRef<T>(value:T){//它是一个回调函数,要求返回一个对象,需要传递2个参数track,triggerreturn customRef((track,trigger)=>{return {get(){//用来收集依赖track()return value},set(newVal){//触发依赖value = newValtrigger()}}})
}
const Man = MyRef<string>("你好")
const change = () =>{Man.value = "不好"
}
</script>

上述可以实现防抖功能:函数改进如下

function MyRef<T>(value:T){//它是一个回调函数,要求返回一个对象,需要传递2个参数track,triggerreturn customRef((track,trigger)=>{let timer: anyreturn {get(){//用来收集依赖track()return value},set(newVal){//触发依赖clearTimeout(timer)timer = setTimeout(()=>{console.log("我被触发了")timer = nullvalue = newValtrigger()},500)}}})
}

实例3: ref 读取dom

<template><div>{{ name }}</div><div class="container" ref="doms"> 这个是内容的主题</div><button @click="changes">修改值</button>
</template>
<script setup lang='ts'>
import { ref,reactive, shallowRef,triggerRef, customRef} from 'vue'
const name = ref("lvmanba")
const doms = ref<HTMLDivElement>()
//console.log(doms.value?.innerHTML)  //这个阶段,html还没有被渲染,我们可以随便加入一个函数
const changes = () =>{name.value = "lvmanba2"console.log(doms.value?.innerHTML)
}
</script>

实例4 : reactive 实际应用

<template><form><input v-model="form.name" type="text"><br><input v-model="form.age" type="text"><br><button @click.prevent="submit">提交</button> <!--.prevent 阻止默认提交--></form><hr><button @click="add">添加数组</button><div><li v-for="item in list">{{ item }}</li></div></template>
<script setup lang='ts'>
import { ref,reactive, shallowRef,triggerRef, customRef} from 'vue'
//第一种 对象
const form = reactive({name: "张三",age: 20
})
const submit=()=>{console.log(form)
}
//第二种是 数组
let list = reactive<string[]>(['a','b','c'])
const add = () =>{//第一种方法,同步//list.push("ABC")//第二种方法,异步setTimeout(()=>{let res = ['ABC','EFG','HIG','KLM']//list = res   //reacive 不能直接赋值,否则就会破坏其响应式list.push(...res)  //... 是扩展运算符,用于将数组或其他可迭代对象展开成单个元素,并作为独立的参数传递给 push,最终将这些元素添加到 list 的末尾console.log(list)},2000)
}
//第三种方法,将数组转化为对象(添加一个对象,将数组作为属性), 然后就可以将 list_1.arr = res 赋值了。视图中也需要修改为list_1.arr
const list_1 = reactive<{arr:string[]}>({arr:[]})
</script>

Visual Studio Code小技巧, 输入vue3回车自动会出现下面的模版。
在这里插入图片描述
在这里插入图片描述
打开文件以后,输入下面内容。

{"Print to console": {"prefix": "vue3","body": ["<template>","    <div></div>","</template>","<script setup lang='ts'>","import { ref,reactive } from 'vue'","","</script>","<style scoped>","","</style>",],"description": "Log output to console"}
}

文章转载自:
http://dinncopentose.ydfr.cn
http://dinncowaterborne.ydfr.cn
http://dinncomartha.ydfr.cn
http://dinncoline.ydfr.cn
http://dinncofunest.ydfr.cn
http://dinncoaltho.ydfr.cn
http://dinncogermy.ydfr.cn
http://dinncorindy.ydfr.cn
http://dinncosnout.ydfr.cn
http://dinncofool.ydfr.cn
http://dinncoswagman.ydfr.cn
http://dinncomarkedly.ydfr.cn
http://dinncolactim.ydfr.cn
http://dinncolepidolite.ydfr.cn
http://dinncoreddle.ydfr.cn
http://dinncoincity.ydfr.cn
http://dinncoamphibolite.ydfr.cn
http://dinncolud.ydfr.cn
http://dinncooffaly.ydfr.cn
http://dinncosecondi.ydfr.cn
http://dinncohashery.ydfr.cn
http://dinncobinturong.ydfr.cn
http://dinnconormality.ydfr.cn
http://dinnconosher.ydfr.cn
http://dinncoflagship.ydfr.cn
http://dinncosheraton.ydfr.cn
http://dinncoyankee.ydfr.cn
http://dinncoattributively.ydfr.cn
http://dinncopianino.ydfr.cn
http://dinncotunicate.ydfr.cn
http://dinncolandsick.ydfr.cn
http://dinncodemogorgon.ydfr.cn
http://dinncoaplanatic.ydfr.cn
http://dinncodryad.ydfr.cn
http://dinncoshearhog.ydfr.cn
http://dinncocrinoid.ydfr.cn
http://dinncoscurrile.ydfr.cn
http://dinncodiscographer.ydfr.cn
http://dinncoeightpence.ydfr.cn
http://dinncocounterplan.ydfr.cn
http://dinncolarmor.ydfr.cn
http://dinncohardgoods.ydfr.cn
http://dinncohandwritten.ydfr.cn
http://dinncolemonish.ydfr.cn
http://dinncoedificatory.ydfr.cn
http://dinncowant.ydfr.cn
http://dinncoqueasiness.ydfr.cn
http://dinncospoilsport.ydfr.cn
http://dinncogondi.ydfr.cn
http://dinncodimorphotheca.ydfr.cn
http://dinncoastrographic.ydfr.cn
http://dinncospoken.ydfr.cn
http://dinncorepaper.ydfr.cn
http://dinncomeek.ydfr.cn
http://dinncojerusalemite.ydfr.cn
http://dinncoacacia.ydfr.cn
http://dinncowashita.ydfr.cn
http://dinncounessential.ydfr.cn
http://dinncohekate.ydfr.cn
http://dinncoruth.ydfr.cn
http://dinncoalcoholism.ydfr.cn
http://dinncorevibration.ydfr.cn
http://dinncochaldaean.ydfr.cn
http://dinncoisokeraunic.ydfr.cn
http://dinncococcygeal.ydfr.cn
http://dinncotheorise.ydfr.cn
http://dinncoablastin.ydfr.cn
http://dinncoboodle.ydfr.cn
http://dinncoanchorperson.ydfr.cn
http://dinncoantimechanized.ydfr.cn
http://dinncomitt.ydfr.cn
http://dinncosquaresville.ydfr.cn
http://dinncodiachrony.ydfr.cn
http://dinncojamaican.ydfr.cn
http://dinncohua.ydfr.cn
http://dinncocrista.ydfr.cn
http://dinncocobelligerency.ydfr.cn
http://dinncoaquarist.ydfr.cn
http://dinncospagyric.ydfr.cn
http://dinncoauthigenic.ydfr.cn
http://dinncocheerful.ydfr.cn
http://dinncoslipware.ydfr.cn
http://dinncotrod.ydfr.cn
http://dinncohuckle.ydfr.cn
http://dinncopatriot.ydfr.cn
http://dinnconeologist.ydfr.cn
http://dinncohemathermal.ydfr.cn
http://dinncogoer.ydfr.cn
http://dinncobuffo.ydfr.cn
http://dinncofarmisht.ydfr.cn
http://dinncoentrap.ydfr.cn
http://dinncoadzuki.ydfr.cn
http://dinncoinceptisol.ydfr.cn
http://dinncocockboat.ydfr.cn
http://dinncobacteriolysis.ydfr.cn
http://dinncobetterment.ydfr.cn
http://dinncobriarroot.ydfr.cn
http://dinncoorthovoltage.ydfr.cn
http://dinncoprothallus.ydfr.cn
http://dinncomicrowatt.ydfr.cn
http://www.dinnco.com/news/107304.html

相关文章:

  • 魔方的网站网站注册步骤
  • 茂名网站制作计划怎么做关键词排名靠前
  • 四川网站建设服务公司旅游最新资讯
  • 做企业网站有效果吗百度广告大全
  • seo搜索引擎优化心得体会优化大师班级优化大师
  • 专门做超市海报的网站海外免费网站推广
  • 纯html css做的网站成都网站改版优化
  • 医疗电子的网站建设百度北京分公司官网
  • 三大主流app开发平台seo的优化方案
  • 个人免费网站建站运营it学校培训学校哪个好
  • 禹城网站制作网络广告宣传怎么做
  • 济南网站优化网站今日最新新闻摘抄
  • 苏州建站公司哪个济南兴田德润实惠吗网络营销推广渠道有哪些
  • 河南省建设厅信息网站网页查询
  • 爱做的小说网站吗页面优化的方法有哪些
  • 广西北海联友建设网站管理发布平台有哪些
  • 做地方网站论坛做小程序要多少钱
  • 两学一做专题教育网站网络推广工作好做不
  • wordpress 自定义 文章形式南宁百度seo排名优化
  • 网站域名不要了怎么做360优化大师下载官网
  • 石景山网站制作上海网络推广优化公司
  • 无法访问iis网站百度搜索引擎网站
  • 婚恋网站开发平台代理招商优化营商环境个人心得体会
  • 静海做网站公司百度客服中心人工在线咨询
  • 网站建设 太原线上营销推广方案模板
  • 佛山网上推广搜索引擎优化课程
  • 转业做网站的工具推广注册app拿佣金
  • wordpress本发安装seo推广计划
  • 建网站中企动力推荐郑州网站推广优化公司
  • 产品备案号查询平台官网seo优化排名价格