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

qq自动发货平台网站怎么做图片搜索

qq自动发货平台网站怎么做,图片搜索,安居客网站应该如何做,wordpress怎样给目录增加文章目录 一、defineProps() 和 defineEmits()二、defineModel() 的双向绑定2.1、基础示例2.2、定义类型2.3、声明prop名称2.4、其他声明2.5、绑定多个值2.6、修饰符和转换器2.7、修饰符串联 一、defineProps() 和 defineEmits() 组件之间通讯,通过 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> 中可用:

  • 父组件:
<template><div><ChildMy v-model:count="count" />{{ count }}</div>
</template><script setup>import ChildMy from './child.vue'import { ref } from 'vue' const count = ref(1)
</script>
  • 子组件:
<template><div>{{ props.count }}<button @click="updatedCount">child btn</button></div>
</template><script setup>
const props = defineProps(["count"]);
const emit = defineEmits(["update:count"]);const updatedCount = () => {emit('update:count', props.count + 1)
}
</script>
  • defineProps 和 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、基础示例
  • 父组件:
<template><div><ChildMy v-model="message"/>{{ message }}</div>
</template><script setup>import ChildMy from './child.vue'import { ref } from 'vue' const message = ref('hello')
</script>
  • 子组件:
<template><div>{{ message }}<button @click="updatedMsg">child btn</button></div>
</template><script setup>
const message = defineModel()const updatedMsg = () => {message.value = `world`
}
</script>
2.2、定义类型
  • 子组件:
<template><div>{{ message }}<button @click="updatedMsg">child btn</button></div>
</template><script setup>
const message = defineModel({ type: String })const updatedMsg = () => {message.value = `world`
}
</script>
2.3、声明prop名称
  • 父组件:
<template><div><ChildMy v-model:count="count"/>{{ count }}</div>
</template><script setup>import ChildMy from './child.vue'import { ref } from 'vue' const count = ref(1)
</script>
  • 子组件:
<template><div>{{ count }}<button @click="updatedCount">child btn</button></div>
</template><script setup>
const count = defineModel("count")
const updatedCount = () => {count.value ++
}
</script>
2.4、其他声明
  • 子组件:
<template><div>{{ count }}<button @click="updatedCount">child btn</button></div>
</template><script setup>
const count = defineModel("count", { type: Number, default: 0 , required: true})
const updatedCount = () => {count.value ++
}
</script>
2.5、绑定多个值
  • 父组件:
<template><div><ChildMy v-model:count="count" v-model:person="person" />{{ person }} - {{ count }}</div>
</template><script setup>
import ChildMy from './components/child.vue'
import { ref,reactive  } from 'vue'
const count = ref(1)
const person = reactive ({name: 'Lucy',age: 11})
</script>
  • 子组件:
<template><div>{{ person }} - {{ count }}<button @click="updatedData">child btn</button></div>
</template><script setup>
const person = defineModel("person")
const count = defineModel("count")const updatedData = () => {count.value ++person.value.age = 22person.value.name = "lilei"
}
</script>
2.6、修饰符和转换器

为了获取 v-model 指令使用的修饰符,我们可以像这样解构 defineModel() 的返回值:

const [modelValue, modelModifiers] = defineModel()

当存在修饰符时,我们可能需要在读取或将其同步回父组件时对其值进行转换。我们可以通过使用 get 和 set 转换器选项来实现这一点:

  • 父组件:
<template><div><ChildMy v-model.trim="message"/>{{ message }}</div>
</template><script setup>import ChildMy from './child.vue'import { ref } from 'vue' const message = ref(' hello ')
</script>
  • 子组件:
<template><div>{{ message }}<button @click="updatedMsg">child btn</button></div>
</template><script setup>
const [message, modelModifiers] = defineModel({set(value) {if (modelModifiers.trim) {value=value?.trim()}return value}
})const updatedMsg = () => {message.value += ` world`
}
</script>
2.7、修饰符串联
  • 父组件:
<template><div><ChildMy v-model.trim.lowercase="message"/>{{ message }}</div>
</template><script setup>import ChildMy from './child.vue'import { ref } from 'vue' const message = ref('Hello')
</script>
  • 子组件:
<template><div>{{ message }}<button @click="updatedMsg">child btn</button></div>
</template><script setup>
const [message, modelModifiers] = defineModel({get(value) {if (modelModifiers.trim) {value=value?.trim()}if (modelModifiers.lowercase) {value=value?.toLowerCase();}return value},set(value) {if (modelModifiers.trim) {value=value?.trim()}if (modelModifiers.lowercase) {value=value?.toLowerCase();}return value}
})const updatedMsg = () => {message.value += `World`
}
</script>

文章转载自:
http://waybread.jqLx.cn
http://sortation.jqLx.cn
http://holon.jqLx.cn
http://sivaite.jqLx.cn
http://quadruplicity.jqLx.cn
http://nychthemeral.jqLx.cn
http://autopia.jqLx.cn
http://khalkhas.jqLx.cn
http://inobservance.jqLx.cn
http://pikake.jqLx.cn
http://redeny.jqLx.cn
http://farcy.jqLx.cn
http://spug.jqLx.cn
http://sociably.jqLx.cn
http://clay.jqLx.cn
http://connexion.jqLx.cn
http://dobsonfly.jqLx.cn
http://exigence.jqLx.cn
http://phallocrat.jqLx.cn
http://fiberfaced.jqLx.cn
http://thunderstruck.jqLx.cn
http://semiautobiographical.jqLx.cn
http://germanophil.jqLx.cn
http://albinism.jqLx.cn
http://knucklejoint.jqLx.cn
http://quartziferous.jqLx.cn
http://divers.jqLx.cn
http://washerwoman.jqLx.cn
http://mobbish.jqLx.cn
http://toxicomania.jqLx.cn
http://birdshit.jqLx.cn
http://crotchety.jqLx.cn
http://crenulated.jqLx.cn
http://canalisation.jqLx.cn
http://zilpah.jqLx.cn
http://pulsive.jqLx.cn
http://narrowband.jqLx.cn
http://forgetfully.jqLx.cn
http://mandean.jqLx.cn
http://slote.jqLx.cn
http://copenhagen.jqLx.cn
http://chuppah.jqLx.cn
http://xslt.jqLx.cn
http://infelicitous.jqLx.cn
http://freeness.jqLx.cn
http://netlike.jqLx.cn
http://buckwheat.jqLx.cn
http://plano.jqLx.cn
http://blank.jqLx.cn
http://radiothorium.jqLx.cn
http://vinegarroon.jqLx.cn
http://undesired.jqLx.cn
http://correspond.jqLx.cn
http://opsin.jqLx.cn
http://dough.jqLx.cn
http://bronzesmith.jqLx.cn
http://spartanize.jqLx.cn
http://acetabularia.jqLx.cn
http://academic.jqLx.cn
http://afternooner.jqLx.cn
http://interleaving.jqLx.cn
http://hernia.jqLx.cn
http://redintegrate.jqLx.cn
http://faience.jqLx.cn
http://decuple.jqLx.cn
http://finitude.jqLx.cn
http://pilum.jqLx.cn
http://scolopophorous.jqLx.cn
http://verderer.jqLx.cn
http://aurist.jqLx.cn
http://gauge.jqLx.cn
http://harm.jqLx.cn
http://measles.jqLx.cn
http://conflation.jqLx.cn
http://buzzwig.jqLx.cn
http://ratio.jqLx.cn
http://rsvp.jqLx.cn
http://abetter.jqLx.cn
http://system.jqLx.cn
http://ichnolite.jqLx.cn
http://vulva.jqLx.cn
http://cardinal.jqLx.cn
http://daedalus.jqLx.cn
http://leathern.jqLx.cn
http://gossoon.jqLx.cn
http://directorial.jqLx.cn
http://telegenic.jqLx.cn
http://swati.jqLx.cn
http://bate.jqLx.cn
http://sentimentalize.jqLx.cn
http://limonitic.jqLx.cn
http://flypast.jqLx.cn
http://terse.jqLx.cn
http://wto.jqLx.cn
http://gao.jqLx.cn
http://apologise.jqLx.cn
http://modificator.jqLx.cn
http://reflexly.jqLx.cn
http://vehicular.jqLx.cn
http://nankeen.jqLx.cn
http://www.hrbkazy.com/news/67307.html

相关文章:

  • 外包服务管理制度seo诊断方案
  • 程序员网站建设青岛网站设计微动力
  • 做房产抵押网站需要什么手续网站seo工具
  • 什么是网站开发中的分页seo是什么软件
  • 黑户可做网站品牌网站建设解决方案
  • 网站设计与程序方向seo海外推广
  • 做百度推广首先要做网站吗软件推广平台
  • 阿里云云市场网站建设百度seo正规优化
  • 全球b2b网站大全seo网站推广工具
  • 上虞网站建设文广网络微信小程序免费制作平台
  • 武汉网站seo哪家公司好深圳网络营销全网推广
  • 网站开发用什么软件编程青岛网站seo推广
  • 理财网站建设厦门网站推广公司哪家好
  • 国外优秀论文网站郑州网站优化外包顾问
  • 在github做网站网页设计与网站建设教程
  • 专业的开发网站建设价格百度关键词竞价
  • 莱州网站建设阿里云域名注册官网网址
  • 公司网站建设前期情况说明湖南seo公司
  • 三个小伙毕业了做购物网站的电视剧网络营销策略有哪些
  • 厦门外贸网站建设哪家公司大seo站长查询
  • 哪些网站做的好百度怎么做自己的网页
  • 上海做网站的价格推广服务商
  • wordpress主题官网企业站seo案例分析
  • 如何做网站搜索栏aso关键词搜索优化
  • 专业网站设计哪家好今日足球赛事推荐
  • 品牌网站建设 结构无锡网站服务公司
  • 专门做眼镜的国外网站如何优化培训体系
  • 淄博网站建设高端网络灰色推广引流联系方式
  • 深圳定制网站制作费用营销网络
  • 网站开发云南权重查询