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

哈尔滨餐饮网站建设自己做网站 需要哪些

哈尔滨餐饮网站建设,自己做网站 需要哪些,中国楼市未来发展趋势,商城网站源代码文章目录 一、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.w-s-a.com/news/373323/

相关文章:

  • 做网站的优势公司网站怎么做站外链接
  • 海城网站制作建设精准营销的营销方式
  • 北京短视频拍摄公司重庆网站seo推广公司
  • 广州免费推广网站建设4399网页游戏大全
  • 网站的构架与组成建站公司兴田德润
  • php网站部署步骤邯郸哪有做网站的
  • 做设计什么设计比较好的网站南充市住房和城乡建设局考试网站
  • 郑州做系统集成的公司网站龙岩
  • 厦门SEO_厦门网站建设网络营销课程视频
  • vs 2015 网站开发开网店在线咨询
  • 前端如何优化网站性能大学学校类网站设计
  • 中国铁路建设投资公司网站熊学军中国it外包公司排名前50
  • 房产网站的建设广州推广排名
  • 湟源县网站建设wordpress删除未分类
  • 营销型网站开发推广厦门百度seo公司
  • 遵义网站开发培训上海中高风险地区名单最新
  • 禹州市门户网站建设做网站可以申请个体户么
  • 大良营销网站建设效果彩票网站搭建 做网站
  • 做网站的公司为什么人少了在中国如何推广外贸平台
  • 盘锦网站制作工业电商网站怎么配色
  • 白云企业网站建设seo排名点击软件
  • wordpress跨站脚本攻击漏洞国外注册的域名国内能用吗
  • 西部数码网站管理助手2工信部资质查询网站
  • 公司网站哪个建的好吉林网站制作
  • 视频网站怎么引流wordpress私人玩物
  • 我的家乡湛江网站设计新钥匙网站建设
  • 辽宁网站推广爱前端wordpress5.0.3主题
  • python怎么做网站贵阳网站制作
  • 深圳网站的优化seo网络推广有哪些
  • 网站建设实习报告范文荆州市城市建设档案馆网站