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

重庆网站制作一般多少钱常用企业网站模板对比

重庆网站制作一般多少钱,常用企业网站模板对比,建设部一建注册网站,网站建设这块是怎么挣钱插槽可以让组件的使用者来决定组件中的某一块区域到底存放什么元素和内容。 使用插槽: 插槽的使用过程其实就是抽取共性、预留不同。将共同的元素、内容依然留在组件内进行封装;将不同的元素使用 slot 作为占位,让外部决定到底显示什么样的…

插槽可以让组件的使用者来决定组件中的某一块区域到底存放什么元素和内容。

使用插槽:

插槽的使用过程其实就是抽取共性、预留不同。将共同的元素、内容依然留在组件内进行封装;将不同的元素使用 slot 作为占位,让外部决定到底显示什么样的元素。

// App.vue
<template><!-- 2. 在父组件中调用子组件时,子组件开始标签和结束标签之间的内容将会被插入到子组件中插槽中 --><AppContent><button>按钮</button></AppContent><AppContent><a href="http:www.com">百度一下</a></AppContent>
</template><script>
import AppContent from './components/AppContent'export default {components: {AppContent,}
}
</script><style scoped>
</style>
// AppContent.vue
<template><div><h1>内容标题</h1><!-- 在子组件中预留插槽 --><slot></slot></div>
</template><script>
export default {
}
</script><style scoped>
</style>

在这里插入图片描述

插槽的默认内容:

<slot></slot>元素开始标签和结束标签之间的内容会作为插槽的默认内容,插槽的默认内容只会在没有提供插入的内容时显示。

// App.vue
<template><!-- 在父组件中调用子组件时,不提供插槽的内容 --><AppContent />
</template><script>
import AppContent from './components/AppContent'export default {components: {AppContent,}
}
</script><style scoped>
</style>
// AppContent.vue
<template><div><h1>内容标题</h1><slot><!-- <slot></slot> 开始标签和结束标签之间的内容会作为插槽的默认内容显示 --><div>这是插槽的默认内容</div></slot></div>
</template><script>
export default {
}
</script><style scoped>
</style>

在这里插入图片描述

具名插槽:

具名插槽:就是给插槽命名,通过 <slot> 元素的 name 属性可以给插槽命名。这样当一个组件中有多个插槽时,就可以区分出来要插入的内容是要插入哪个插槽中。

一个不带 name 的插槽,默认隐含的名字是 default。

// App.vue
<template><NavBar><!-- 2. 在父组件中,使用 template 元素包裹要插入到插槽中的内容,通过 v-slot:插槽的名称 来决定要插入哪个插槽中 --><!-- v-slot:[变量名] 可以通过这种方式来动态地绑定插槽的名称 --><!-- v-slot 的缩写为 # --><template v-slot:left><button>返回</button></template><template v-slot:center><input /></template><template v-slot:right><button>搜索</button></template></NavBar>
</template><script>
import NavBar from './components/NavBar'export default {components: {NavBar,}
}
</script><style scoped>
</style>
// NavBar.vue
<template><div class='navbar'><div class="left"><!-- 1. 在子组件中通过 name 属性给插槽命名 --><slot name="left"></slot></div>   <div class="center"><slot name="center"></slot></div> <div class="right"><slot name="right"></slot></div> </div>
</template><script>
export default {
}
</script><style scoped>
</style

作用域插槽:

作用域插槽的核心就是能够将子组件中的数据传递给父组件的插槽来使用。

// App.vue
<template><AppContent><!-- 2. 在父组件中,使用 template 元素包裹要插入到插槽中的内容,通过 v-slot:插槽名称="slotProps" 可以获取到子组件中指定插槽传递过来的数据 --><template v-slot:default="slotProps"><p>{{ slotProps.content }}</p></template></AppContent>
</template><script>
import AppContent from './components/AppContent'export default {components: {AppContent,}
}
</script><style scoped>
</style>
// AppContent.vue
<template><div><h1>子组件的标题</h1><!-- 1. 在子组件中,通过给 slot 元素添加属性的方式给父组件传递数据 --><slot content="子组件的内容"></slot></div>
</template><script>
export default {
}
</script><style scoped>
</style>
http://www.yayakq.cn/news/489251/

相关文章:

  • 福州微信网站整站seo怎么做
  • 网站建设设计培训班jquery做网站浏览量
  • 没有网站怎么做网络推广北京公司注册网站
  • 培训学校网站系统企业网站作用
  • 长沙网站建设要多少钱网站建设自我总结
  • 巩义网站推广怎么做互联网保险的运营模式
  • 彩票网站链接怎么做东莞市建设管理局
  • 湖南监理建设协会网站网站设计工作流程
  • 如何免费建站网站策划工资一般多少
  • 建设银行手机银行官方网站下载安装佛山制作网站公司推荐
  • 重庆找做墩子网站音乐接单推广app平台
  • 长春站建了多少年大千设计装饰有限公司
  • 腾讯云建站平台免费自己做网站软件
  • 郑州营销型网站建设哪家好中企动力做网站价格
  • 网站如何屏蔽ip段扬州网络推广公司
  • 东莞百度网站排名优化网站建设5iec
  • 中国建设招聘信息网站免费图片在线生成
  • 电子商务企业网站建设发展论文网站服务器租用有什么好
  • 吉安网站建设优化服务网站基础模板
  • 郑州网站关键瀑布流资源网站模板
  • node框架做网站智能物联网综合管理平台
  • 奥特蛋的做网站营销传播方式有哪些
  • 木地板企业网站模版招商网站建设
  • 在深圳做it的要做网站网站吗用wordpress写网页
  • 在哪个网站有兼职做网页设计网站费用
  • 一件代发48个货源网站永州城乡建设中等职业技术学校网站
  • 商业网站建设规划范文直播软件视频软件
  • 临沂网站制作计划厦门做商城网站
  • 网站建设cach目录自己做装修图网站
  • 吴忠市建设局网站做任务推广网站