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

无代码网站建设网络虚拟号

无代码网站建设,网络虚拟号,北京网讯百度科技有限公司,wordpress更换域名目录 定义语法使用场景场景一场景二场景三tips只有一个默认插槽时 定义 在Vue中#xff0c; v-slot 指令用于定义插槽的模板内容。它用于在父组件中传递内容到子组件中的插槽。 v-slot 指令可以用于 标签或组件标签上#xff0c;以便在子组件中使用插槽。 语法 使用 v-slo… 目录 定义语法使用场景场景一场景二场景三tips只有一个默认插槽时 定义 在Vue中 v-slot 指令用于定义插槽的模板内容。它用于在父组件中传递内容到子组件中的插槽。 v-slot 指令可以用于 标签或组件标签上以便在子组件中使用插槽。 语法 使用 v-slot 指令时可以使用以下两种语法 缩写语法 # 符号表示 v-slot 指令后面跟插槽名称。 template #插槽名称!-- 插槽内容 -- /template完整语法 v-slot 指令后面跟着 : 后面是插槽名称。 template v-slot:插槽名称!-- 插槽内容 -- /template使用场景 v-slot 指令的使用场景包括但不限于以下几种 在组件中使用插槽将父组件中的内容传递给子组件。在子组件中使用具名插槽根据插槽名称渲染不同的内容。在子组件中使用作用域插槽将子组件中的数据传递到父组件中进行渲染。 场景一 在组件中使用插槽将父组件中的内容传递给子组件。 父组件 templatedivchild-componenttemplate v-slot:default!-- 插槽内容 --pThis is the content passed from the parent component./p/template/child-component/div /template子组件 templatedivslot/slot/div /template场景二 在子组件中使用具名插槽根据插槽名称渲染不同的内容 父组件 templatedivchild-componenttemplate v-slot:header!-- 插槽内容 --h1Header Content/h1/templatetemplate v-slot:body!-- 插槽内容 --pBody Content/p/template/child-component/div /template子组件 templatedivslot nameheader/slotslot namebody/slot/div /template场景三 在子组件中使用作用域插槽将子组件中的数据传递到父组件中进行渲染 父组件 templatedivchild-componenttemplate v-slot:defaultslotProps!-- 插槽内容 --p{{ slotProps.message }}/p/template/child-component/div /template子组件 templatedivslot :messagemessage/slot/div /templatescript export default {data() {return {message: Hello from child component!};} }; /script在router-view中的应用拿到router-view中的Component值同时利用component 标签动态渲染组件 router-view v-slot{ Component, route }transition appear namefade-transform modeout-inkeep-alive :includekeepAliveNamecomponent :isComponent v-ifisRouterShow :keyroute.fullPath //keep-alive/transition/router-viewtips 如果父组件没有向插槽传入值则子组件会显示原来的内容当传入具体的值时则会覆盖掉插槽内的内容 子组件 templateslot namea1 :contentslot_data h1child-123/h1 /slot /templatescript langts setup const slot_data child-content; /scriptstyle scoped/style父组件 templatedivh5slot-test/h5child!-- template #a1{ content }div{{ content }}/div/template --/child/div /templatescript langts setup import child from ./child.vue; /scriptstyle scoped/style此时注释掉插值代码结果如图只会显示原来槽内内容 父组件代码修改如下 templatedivh5slot-test/h5childtemplate #a1{ content }div{{ content }} 我是父组件/div/template/child/div /templatescript langts setup import child from ./child.vue; /scriptstyle scoped/style显示内容如图所示则会覆盖掉原来槽值 在v-slot中既可以由子组件向父组件传值slot_data又可以由父组件向子组件传递html内容可以看做是‘’双向的‘’ 在一些场景比如子组件渲染的内容既需要子组件数据又需要父组件数据时可以考虑使用插槽来完成 props同样也可以向子组件传值在子组件中同一渲染完成这是之前一直使用的方式之后可以考虑使用插槽拿到子组件中的值又可以向子组件传递内容 只有一个默认插槽时 可以直接这样写类似于上述router-view的用法 子组件 templateslot :contentslot_data :content2slot_data2 /slot /templatescript langts setup const slot_data child-content; const slot_data2 child-content2; /script父组件 contentcontent2采用解构赋值直接从slotProps值默认传递变量的名称中得到templete也可以省略child标签内的所有值都会被传入插槽 templatedivh5slot-test/h5child v-slot{ content, content2 }!-- h1{{ content }}/h1 --{{ content }}{{ content2 }}784561/child/div /templatescript langts setup import child from ./child.vue; /script结果如图
http://www.yutouwan.com/news/362102/

相关文章:

  • 老城网站建设wordpress控制上下页链接
  • 广东做网站公司东莞头条最近15天新闻
  • 网站建设灬金手指下拉十四用糖做的网站
  • 扬州建设公司网站益阳做网站
  • 网站开发设计总结及心得体会哪个网站专业做饲料
  • 个人网站做什么内容网站如何调用百度地图
  • 珠海电商网站制作私自建立网站网站判决书
  • 一个网站怎么赚钱网站建设关键性开发工具
  • 免费域名注册和免费建站滨州做网站的公司
  • 网站规划与建设的流程与方法 高中信息技术wordpress博客vieu模板
  • 网站建设前的分析第一小节内容做动态文字的网站
  • 网络网站设计培训如何自己做网站并开发软件
  • 成都建站培训seo外链查询工具
  • 视频播放网站建设手机版网站快照如何做
  • 网站如何做网页查询网络服务公司名字
  • 河南seo网站开发网站建设的基本术语
  • 网站建设前准备做的网站怎么联网
  • php网站修改主页内容注册公司需要登录的网址
  • 宁波网站建设开发多少钱网页制作的论文
  • 网站设置价格错误不愿意发货常用网站建设技术是什么意思
  • wordpress主题 网站大全刚成立公司如何做网站
  • 龙口建网站公司价格如何做网站栏目
  • 如何修改网站模版阿里云建设网站买哪个服务
  • 网站制作wordpress外网访问群晖wordpress
  • 艺术视频手机网站可以做吗中高端社交网站建设服务商
  • 创意网站设计团队如何做企业交易网站
  • 企业网站备案 优帮云WordPress火车头规则
  • 网站互动方式钦州建设银行社招聘网站
  • 公司备案号查询网站wordpress163邮件
  • 有了域名 接下来怎么做网站别墅设计 网站模板