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

网站可以叫做系统吗建网站学什么

网站可以叫做系统吗,建网站学什么,四川省微信网站建设,今天军事新闻最新消息详细前言#xff1a;如何实现组件的灵活使用#xff0c;今天学习组件封装用到的props、slot和emit。 目录 props 子组件 父组件 示例代码 slot 示例代码 作用域插槽 emit 示例代码 props 需要实现在其他组件中使用同一个子组件。 子组件 子组件#xff08;所谓子组件… 前言如何实现组件的灵活使用今天学习组件封装用到的props、slot和emit。 目录 props 子组件 父组件 示例代码 slot 示例代码 作用域插槽 emit 示例代码 props 需要实现在其他组件中使用同一个子组件。 子组件 子组件所谓子组件就是封装好的组件供其他组件使用 子组件定义了sonName div我是MRJJ_9{{sonName}}/div defineProps([sonName]) 或 const propsdefineProps([sonName]) props是只读的尽量不要去修改 定义多个 const propsdefineProps([sonName1,sonName2]) 但通常使用数组定义 const props defineProps({   sonName1: Object,   sonName: Number,}) 父组件 父组件所谓父组件就是引用封装好的其他子组件 Mrjj-Counter :sonNamesonName/Mrjj-Counter let sonNameref(引用子组件) 示例代码 子组件设置 templatediv我是MRJJ_9的第一个属性类型为字符串内容是{{ sonName1 }},第二个属性类型是数字数值为{{ sonName2 }}/div /template script setup const props defineProps({sonName1: String,sonName2: Number, }) console.log(属性1,props.sonName1) console.log(属性2,props.sonName2) /script style langscss scoped /style 父组件设置 templatemrjj-son :sonName1sonName1 :sonName2sonName2/mrjj-son /template script setup import MrjjSon from /components/MrjjSon.vue import { ref } from vue let sonName1 ref(hello,world!!!) let sonName2 ref(999) /script style langscss scoped /style 要注意不能去修改里面的值 slot 需要实现在其他组件中使用同一个组件子组件但组件样式的有所区别 这就需要用到插槽slot其作用是传参时可以带上HTML结构 子组件带上slot {{ sonName }}slot/slot 父组件将需要传递的内容写到子组件标签里 mrjj-sonstrong{{sonName }}/strong/mrjj-son 具名插槽给插槽命名 有多个值时 子组件加上name 父组件用v-slot:插槽名或#插槽名 示例代码 子组件设置 templatediv{{ sonName1 }}slot namemrjj1/slot{{ sonName2 }}slot namemrjj2/slot/div /template script setup const props defineProps({sonName1: String,sonName2: Number }) /script style langscss scoped /style 父组件设置 templatemrjj-sontemplate #mrjj1strong{{ sonName1 }}/strong/templatetemplate #mrjj2i{{ sonName2 }}/i/template/mrjj-son /template script setup import MrjjSon from /components/MrjjSon.vue import { ref } from vue let sonName1 ref(hello,world!!!) let sonName2 ref(999) /script style langscss scoped /style 效果展示 作用域插槽 子组件 templatediv{{ sonName3 }}slot namemrjj3 :timescount :mrjj1name/slot/div /template script setup import { ref } from vueconst props defineProps({sonName3: String }) let count ref(0) let name ref(计数器) /script style langscss scoped /style 父组件  template #mrjj3{ times } templatemrjj-sontemplate #mrjj3{ times }i{{ sonName3 }}/iTimes :timestimes/Times/template/mrjj-son /template script setup import MrjjSon from /components/MrjjSon.vue import Times from /components/Times.vue import { ref } from vue let sonName3 ref() /script style langscss scoped /style 引用的Time.vue文件 templateh1显示Mrjj{{ times }}/h1 /template script setup defineProps([times]) /script emit 需求增加一个关闭、打开的组件功能 用到emitemit干了什么事情呢在子组件中触发一个事件在父组件中进行监听。 示例代码 子组件定义一个自定义事件 templatediv{{ sonName1 }}slot namemrjj1/slot{{ sonName2 }}slot namemrjj2/slotbutton clickcloseSon点我关闭/button/div /templatescript setup const props defineProps({sonName1: String,sonName2: Number }) const emit defineEmits([closeMrjj])function closeSon() {console.log(关闭按钮被点击了)emit(closeMrjj) } /script style langscss scoped /style 父组件绑定事件 templatemrjj-son closeMrjjcloseMrjj v-ifisClosetemplate #mrjj1strong{{ sonName1 }}/strong/templatetemplate #mrjj2i{{ sonName2 }}/i/template/mrjj-sonbutton v-else click($event) (isClose true)点我打开/button /template script setup import MrjjSon from /components/MrjjSon.vue import { ref } from vue let sonName1 ref(hello,world!!!) let sonName2 ref(999) let isClose ref(false) function closeMrjj() {isClose.value false } /script style langscss scoped /style 效果展示 点我关闭按钮点击后调用了closeSon函数可以看到console输出的信息。 点击展开后也可以展示出内容。
http://www.w-s-a.com/news/33809/

相关文章:

  • 网站职能建设论文做外贸都有哪些网站
  • 网站建设项目需求分析房地产网站源码
  • 网站充值提现公司账务怎么做中国能建设计公司网站
  • 网站信息资源建设包括哪些网站网站做维护
  • 网站性能优化的方法有哪些建设施工合同网站
  • 郑州建设企业网站山西省住房和城乡建设厅网站
  • 做网站的去哪找客户正规制作网站公司
  • 网站代理访问是什么意思外国优秀设计网站
  • 合肥个人建站模板网络技术服务有限公司
  • 做网站什么公司好dw企业网站开发教程
  • 怎么做自己的个人网站宝安网站设计哪家最好
  • 浩博建设集团网站站长网站统计
  • 电商网站开发视频seo排名优化方式方法
  • 宿迁市住房城乡建设局网站wordpress纯图片主题
  • 广州建设网站 公司湖北省建设信息网官网
  • 网站建立时间查询做百度移动网站优化排
  • 网站建设和运行费用qq恢复官方网站
  • 可以免费建立网站吗免费的网络营销方式
  • 天津企业设计网站建设wordpress标题字体大小
  • 上高县城乡规划建设局网站创业项目
  • 钓鱼网站在线下载广州网站设计哪里好
  • 做阿里国际网站会有成效吗wordpress微博同步
  • 西安网站建设云速网络网站运营情况怎么写
  • 免费建网站的网站微信商城分销系统方案
  • 烟台网站seo服务友情链接有哪些展现形式
  • 什么是移动网站开发免费网站开发框架
  • 做网站 创业wordpress子菜单
  • 门户网站类型有哪些权重7以上的网站
  • 政务网站建设论文android app开发教程
  • 网站开发实训h5总结个人网站注册平台要多少钱