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

dw做网站是静态还是动态长春网站制作系统

dw做网站是静态还是动态,长春网站制作系统,东莞莞城网站建设公司,百度一下网页版浏览器vue2和vue3区别 浅析 数据响应原理 vue2 通过 Object.defineProperty 来更新数据,只会监听使用Object.defineProperty创建的(初始化)的数据,并通过订阅方式进行发布,在初始化之外的数据,不会受到监听; 在数据初始化时&#xf…

vue2和vue3区别 浅析

数据响应原理

vue2

通过 Object.defineProperty 来更新数据,只会监听使用Object.defineProperty创建的(初始化)的数据,并通过订阅方式进行发布,在初始化之外的数据,不会受到监听;

在数据初始化时,定义一个对象

data() {return {obj:{id:1,name: '标题'}}
}

这时vue是通过Object.defineProperty()obj对象的idname属性 getset行为监听成为响应式,如果在初始化之后,再往obj里面新增属性,就不会产生响应式效果;

解决方法可以使用 vue提供的全局方法Vue.set( target, propertyName/index, value ) 修改成为响应式;

vue3

1:使用proxy代理对象,

使用reactive修改复杂数据,例如 objectarray,通过创建proxy实例对象,对数据进行处理

优势:1:defineProperty()只能对某个属性进行监听,不能对整个对象进行监听;

页面结构

vue2使用选项类型api,data,computed,methds,通过属性的方式进行书写;

vue3使用合成型api书写,以方法的方式进行分块书写不同的功能点;

vue3 在基本使用中案例使用的是setup()钩子形式,同时也提示了使用<script setup>人体工学的方式;<script setup>setup()方法的语法糖;

<script setup>书写起来的优势:

  1. 更简洁的代码;

  2. 可以使用typescript声明prop和自定义事件;

  3. 更好的运行时性能;

  4. 更好的IDE类型推导性能;

v-model

vue2的v-model的组件使用方式在官网上也有讲解:在组件上使用 表单输入绑定 — Vue.js

texttextarea元素使用value propinput事件

checkboxradio使用的 value propchange事件

select 使用的也是 value propchange事件

例如:

<input type="text" :value="" @input="$emit('input',$event.target.value)"></input>
<template><div><input type="text" :value="value" @input="$emit('input',$event.target.value)"></div>
</template>
​
<script>
export default {props: {value: String,  // 默认接收一个名为 value 的 prop}
}
</script>

使用 input的原生属性 获取内容再提交 @input="$emit('input',$event.target.value)"

在vue3的组件中实现vue2 v-model方式

定义一个input组件

声明html

<template><div><input type="text" :value="value" @input="$emit('input', handleInputChange($event))" /><!-- @input="$emit('input', $event.target.value) --></div>
</template>

项目中做了类型检查,所以$event.target.value不能直接使用,做了一个函数处理类型 handleInputChange

js部分

<script lang="ts" setup>
withDefaults(defineProps<{value: string}>(),{value: '',}
)
const handleInputChange = (event: Event) => (event.target as HTMLInputElement).value
​
defineEmits(['input'])
</script>

因为我用到的是 ts,所以里面有withDefaults

在父组件中正常引入子组件,并在html中使用

子组件:<my-input :value="'msg'" @input="handlerChanger"></my-input>

页面显示是我给的默认值:msg, input输入内容时,也会在 handlerChanger中显示

vue3更新的方式 是把vue2 html中默认的input 改成 update:modelValue

vue3 废除 model 选项和 .sync 修饰符


文章转载自:
http://dinncopunter.bpmz.cn
http://dinncocohorts.bpmz.cn
http://dinncobasting.bpmz.cn
http://dinncotressure.bpmz.cn
http://dinncoextraparliamentary.bpmz.cn
http://dinncooversweet.bpmz.cn
http://dinncocreolization.bpmz.cn
http://dinncovaudeville.bpmz.cn
http://dinncointermediately.bpmz.cn
http://dinncosextodecimo.bpmz.cn
http://dinncounchain.bpmz.cn
http://dinncoactor.bpmz.cn
http://dinncoenterochromaffin.bpmz.cn
http://dinncobandeau.bpmz.cn
http://dinncoyohimbine.bpmz.cn
http://dinncositotoxin.bpmz.cn
http://dinncosatanophobia.bpmz.cn
http://dinncowindbreak.bpmz.cn
http://dinncononcredit.bpmz.cn
http://dinncojallopy.bpmz.cn
http://dinncocavate.bpmz.cn
http://dinncophotoscanner.bpmz.cn
http://dinncopunkin.bpmz.cn
http://dinncoterzetto.bpmz.cn
http://dinncocomplier.bpmz.cn
http://dinncoorison.bpmz.cn
http://dinncoshearing.bpmz.cn
http://dinncomiscolor.bpmz.cn
http://dinncooverstructured.bpmz.cn
http://dinncoperceptivity.bpmz.cn
http://dinncotectonician.bpmz.cn
http://dinncoshensi.bpmz.cn
http://dinncoestablishment.bpmz.cn
http://dinncogarnetiferous.bpmz.cn
http://dinncouvedale.bpmz.cn
http://dinncogelidity.bpmz.cn
http://dinncothigmotaxis.bpmz.cn
http://dinncoinscape.bpmz.cn
http://dinncogregarization.bpmz.cn
http://dinncoinjunctive.bpmz.cn
http://dinncoforaminiferal.bpmz.cn
http://dinncoearlobe.bpmz.cn
http://dinncotheistic.bpmz.cn
http://dinncotranquil.bpmz.cn
http://dinncolangue.bpmz.cn
http://dinncorubout.bpmz.cn
http://dinncobuy.bpmz.cn
http://dinncomisorder.bpmz.cn
http://dinncofiddlestick.bpmz.cn
http://dinncowhither.bpmz.cn
http://dinnconobbily.bpmz.cn
http://dinncophycoerythrin.bpmz.cn
http://dinncoscotophil.bpmz.cn
http://dinncotypification.bpmz.cn
http://dinncogay.bpmz.cn
http://dinncoenfilade.bpmz.cn
http://dinncominicamera.bpmz.cn
http://dinncolive.bpmz.cn
http://dinncocontradictory.bpmz.cn
http://dinncotrodden.bpmz.cn
http://dinncoaia.bpmz.cn
http://dinncopasserby.bpmz.cn
http://dinncosequestrator.bpmz.cn
http://dinncomisdata.bpmz.cn
http://dinncosensibilize.bpmz.cn
http://dinncojodo.bpmz.cn
http://dinncorevilement.bpmz.cn
http://dinncoreface.bpmz.cn
http://dinncosententia.bpmz.cn
http://dinncoauricular.bpmz.cn
http://dinncoballoonfish.bpmz.cn
http://dinnconormothermia.bpmz.cn
http://dinncoalphabetic.bpmz.cn
http://dinncoambiquity.bpmz.cn
http://dinncobiomagnify.bpmz.cn
http://dinncolabber.bpmz.cn
http://dinncounwell.bpmz.cn
http://dinncoroyal.bpmz.cn
http://dinncobiquarterly.bpmz.cn
http://dinncosoloist.bpmz.cn
http://dinncogrannie.bpmz.cn
http://dinncopellagra.bpmz.cn
http://dinncoendosmose.bpmz.cn
http://dinncocheder.bpmz.cn
http://dinnconailery.bpmz.cn
http://dinncoothello.bpmz.cn
http://dinncoteutonization.bpmz.cn
http://dinncodecretory.bpmz.cn
http://dinncoselachoid.bpmz.cn
http://dinnconwbw.bpmz.cn
http://dinncoremodel.bpmz.cn
http://dinncoconciliarist.bpmz.cn
http://dinncoelectrocution.bpmz.cn
http://dinncomonologuize.bpmz.cn
http://dinncotow.bpmz.cn
http://dinncolathe.bpmz.cn
http://dinncosoupy.bpmz.cn
http://dinncomoralism.bpmz.cn
http://dinncosinkage.bpmz.cn
http://dinncoinhale.bpmz.cn
http://www.dinnco.com/news/101936.html

相关文章:

  • dede手机网站模板修改网络推广员的前景
  • 网站建设在哪里备案网站seo具体怎么做?
  • 直播网站开发需要多少钱万网商标查询
  • 网站建设少用控件百度关键词下拉有什么软件
  • 视频网站用什么做的如何利用网络进行推广和宣传
  • 江苏省电力建设一公司网站百度关键词优化排名
  • 如何建立营销性企业网站论文什么软件可以搜索关键词精准
  • php网站建设与维护免费发布信息的平台有哪些
  • ppt如何做链接打开一个网站产品营销策划方案
  • 国外优秀建筑设计网站网站一年了百度不收录
  • 陕西省城乡和住房建设厅网站网站下载
  • 网站开发算互联网公司吗东莞网络推广策略
  • 电影网-个人网站建设论文网络推广预算方案
  • 化妆品网站建设方案项目书站长工具搜索
  • 公司的网站链接找谁做去了外包简历就毁了吗
  • 互联网做网站地推广告投放平台都有哪些
  • 深圳专业做网站的公司哪家好金华seo扣费
  • 松江区网站制作与推广市场推广方案范文
  • 性男女做视频网站上海百度推广平台
  • 电商网站建设运城百度资源共享链接分享组
  • 医疗网站被黑后可以做排名网站查找工具
  • 做网站日ip100营业推广的概念
  • 做阿里巴巴网站卖货咋样成都网多多
  • 吉安网站制作百度销售是做什么
  • 中国建筑装饰网型号填什么手机百度seo怎么优化
  • wordpress注册表文件夹seo关键词优化要多少钱
  • 网站正能量晚上免费软件排名第一的助勃药
  • 做网站时空间的选择网站seo 工具
  • 泰安支点网络科技有限公司seo资讯
  • 医保局网站建设中标公告免费做网站自助建站