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

做品牌网站的徐州seo推广

做品牌网站的,徐州seo推广,wordpress注册页插件,装修找客户去哪个网站文章目录 一、defineProps() 和 defineEmits()二、defineModel() 的双向绑定2.1、基础示例2.2、定义类型2.3、声明prop名称2.4、其他声明2.5、绑定多个值2.6、修饰符和转换器2.7、修饰符串联 一、defineProps() 和 defineEmits() 组件之间通讯#xff0c;通过 props 和 emits… 文章目录 一、defineProps() 和 defineEmits()二、defineModel() 的双向绑定2.1、基础示例2.2、定义类型2.3、声明prop名称2.4、其他声明2.5、绑定多个值2.6、修饰符和转换器2.7、修饰符串联 一、defineProps() 和 defineEmits() 组件之间通讯通过 props 和 emits 进行通讯是单向数据流 子组件不能改变父组件传递给它的 prop 属性推荐的做法是它抛出事件通知父组件自行改变绑定的值。 为了在声明 props 和 emits 选项时获得完整的类型推导支持我们可以使用 defineProps 和 defineEmits API它们将自动地在 script setup 中可用 父组件 templatedivChildMy v-model:countcount /{{ count }}/div /templatescript setupimport ChildMy from ./child.vueimport { ref } from vue const count ref(1) /script子组件 templatediv{{ props.count }}button clickupdatedCountchild btn/button/div /templatescript setup const props defineProps([count]); const emit defineEmits([update:count]);const updatedCount () {emit(update:count, props.count 1) } /scriptdefineProps 和 defineEmits 都是只能在 二、defineModel() 的双向绑定 这个宏可以用来声明一个双向绑定 prop通过父组件的 v-model 来使用。 在底层这个宏声明了一个 model prop 和一个相应的值更新事件。如果第一个参数是一个字符串字面量它将被用作 prop 名称否则prop 名称将默认为 “modelValue”。在这两种情况下你都可以再传递一个额外的对象它可以包含 prop 的选项和 model ref 的值转换选项。 defineModel() 的双向绑定是在编译之后创建了一个model的ref变量以及一个modelValue的props并且watch了props中的modelValue当子组件中的modelValue更新时会触发update:modelValue事件当父组件接收到这个事件时候同时更新父组件的变量。 2.1、基础示例 父组件 templatedivChildMy v-modelmessage/{{ message }}/div /templatescript setupimport ChildMy from ./child.vueimport { ref } from vue const message ref(hello) /script子组件 templatediv{{ message }}button clickupdatedMsgchild btn/button/div /templatescript setup const message defineModel()const updatedMsg () {message.value world } /script2.2、定义类型 子组件 templatediv{{ message }}button clickupdatedMsgchild btn/button/div /templatescript setup const message defineModel({ type: String })const updatedMsg () {message.value world } /script2.3、声明prop名称 父组件 templatedivChildMy v-model:countcount/{{ count }}/div /templatescript setupimport ChildMy from ./child.vueimport { ref } from vue const count ref(1) /script子组件 templatediv{{ count }}button clickupdatedCountchild btn/button/div /templatescript setup const count defineModel(count) const updatedCount () {count.value } /script2.4、其他声明 子组件 templatediv{{ count }}button clickupdatedCountchild btn/button/div /templatescript setup const count defineModel(count, { type: Number, default: 0 , required: true}) const updatedCount () {count.value } /script2.5、绑定多个值 父组件 templatedivChildMy v-model:countcount v-model:personperson /{{ person }} - {{ count }}/div /templatescript setup import ChildMy from ./components/child.vue import { ref,reactive } from vue const count ref(1) const person reactive ({name: Lucy,age: 11}) /script子组件 templatediv{{ person }} - {{ count }}button clickupdatedDatachild btn/button/div /templatescript setup const person defineModel(person) const count defineModel(count)const updatedData () {count.value person.value.age 22person.value.name lilei } /script2.6、修饰符和转换器 为了获取 v-model 指令使用的修饰符我们可以像这样解构 defineModel() 的返回值 const [modelValue, modelModifiers] defineModel()当存在修饰符时我们可能需要在读取或将其同步回父组件时对其值进行转换。我们可以通过使用 get 和 set 转换器选项来实现这一点 父组件 templatedivChildMy v-model.trimmessage/{{ message }}/div /templatescript setupimport ChildMy from ./child.vueimport { ref } from vue const message ref( hello ) /script子组件 templatediv{{ message }}button clickupdatedMsgchild btn/button/div /templatescript setup const [message, modelModifiers] defineModel({set(value) {if (modelModifiers.trim) {valuevalue?.trim()}return value} })const updatedMsg () {message.value world } /script2.7、修饰符串联 父组件 templatedivChildMy v-model.trim.lowercasemessage/{{ message }}/div /templatescript setupimport ChildMy from ./child.vueimport { ref } from vue const message ref(Hello) /script子组件 templatediv{{ message }}button clickupdatedMsgchild btn/button/div /templatescript setup const [message, modelModifiers] defineModel({get(value) {if (modelModifiers.trim) {valuevalue?.trim()}if (modelModifiers.lowercase) {valuevalue?.toLowerCase();}return value},set(value) {if (modelModifiers.trim) {valuevalue?.trim()}if (modelModifiers.lowercase) {valuevalue?.toLowerCase();}return value} })const updatedMsg () {message.value World } /script
http://www.hkea.cn/news/14560395/

相关文章:

  • 网站开发主要框架 后端天津自动seo
  • cdr做的网站效果怎么直接用wordpress+重复插件
  • 渝北集团网站建设手机网站成功案例
  • 正能量网站不用下载直接进入wordpress 协会主题
  • 网站做两个月百度没有录取济南网站制作工具
  • 网站建设预算申请图片滤镜网站开发
  • 北滘网站建设公司菏泽网站建设优惠臻动传媒
  • 网站建设分销协议简述网站建设及维护全过程
  • 网站开发与建设方向公司部门分类
  • 帝国网站模板建设西安关键词优化排名
  • 单位网站建设框架网络推广方案推荐
  • 一个wordpress两个站点网站托管是什么
  • 网站单页推广怎么根据别人的网站做自己的网站
  • 太原网站域名开发xuzhou公司网站制作
  • 外贸网站开发莆田软件开发合同模板
  • 个人网站源码phpwordpress做书籍目录
  • 一键建网站做影视网站该怎么发展
  • 网站开发过程及要点阿里云虚拟主机建站教程
  • 大同建设局网站毕业设计网页
  • 有哪些学做衣服的网站有哪些嘉兴seo网站排名
  • php做的静态网站怎么加密网站开发实践教程
  • 国外做鞋子的网站网页制作作品免费下载
  • 合肥的网站建设公司哪家好微微营销官网
  • 葫芦岛建设工程信息网站网页制作软件哪个好
  • 个人做网站要注意什么条件莱芜金点子招小时工
  • 网站建站管理系统去了哪找网站建设公司
  • 网站服务器怎么维护做封面图的网站
  • dede学校网站企业自建平台有哪些
  • 东莞 网站建设企业网页设计软件免费下载
  • 罗定城乡建设规划局网站北京网站推广营销策划