首页 > 其他分享 >vue--day67--作用域插槽

vue--day67--作用域插槽

时间:2023-08-23 22:46:47浏览次数:42  
标签:Category vue width -- 100% 作用域

1. App.vue

 

<template> <div class="container">  
<Category title="游戏" > <template scope="atgui">
<ul > <li v-for="(g,index) in atgui.games" :key="index">{{g}}</li> </ul> </template>     </Category>
<Category title="游戏" >
<!--结构赋值--> <template scope="{games}"> <ol > <li v-for="(g,index) in games" :key="index">{{g}}</li> </ol> </template> </Category>
<Category title="游戏" > <template scope="{games}"> <h4 v-for="(g,index) in games" :key="index">{{g}}</h4> </template> </Category>
   
  </div>     </template>   <script> import Category from './components/Category.vue'; export default { name: 'App', components:{ Category },   }

</script>
<style> .container,.foot{ display: flex; justify-content: space-around; }
h4{ text-align: center; }
video{ width:100% }
img{ width:100% } </style>    2. Category.vue <template> <div class="category"> <h3>{{title}}分类</h3> <!-- 定义一个插槽(挖个坑,等着组件的使用者进行填充) --> <slot :games="games">我是默认的一些内容</slot>     </div> </template>
<script> export default { name:'Category', props:['title'], data(){ return{ foods:['火锅','烧烤','小龙虾','牛排'], games:['红色警戒','劲舞团','穿越火线','超级玛丽'], films:['教父','拆弹专家','你好李焕英','小李飞刀'] } } } </script>
<style scoped> .category{ background-color: skyblue; width: 200px; height: 300px; } h3{ text-align: center; background-color: orange; } video{ width: 100%; } img{ width: 100%; } </style>    

标签:Category,vue,width,--,100%,作用域
From: https://www.cnblogs.com/satisfysmy/p/17652943.html

相关文章

  • 【剑指Offer】41、和为S的连续正数序列
    【剑指Offer】41、和为S的连续正数序列题目描述:小明很喜欢数学,有一天他在做数学作业时,要求计算出9~16的和,他马上就写出了正确答案是100。但是他并不满足于此,他在想究竟有多少种连续的正数序列的和为100(至少包括两个数)。没多久,他就得到另一组连续正数和为100的序列:18,19,......
  • Spring Bean 生命周期
    实例化1、解析xml配置或注解配置的类,得到BeanDefinition;2、通过BeanDefinition反射创建Bean对象;属性赋值3、对Bean对象进行属性填充;初始化回调4、回调实现了Aware接口的方法,如BeanNameAware;5、调用BeanPostProcessor的初始化前方法;6、调用init初始化方法;7、调用BeanPostP......
  • error: undefined reference to `cv::imread(cv::String const&, int)' 解决方法
    方法1原文链接:https://blog.csdn.net/WhiteLiu/article/details/72901520编译时出现下列错误:undefinedreferenceto'cv::imread(cv::Stringconst&,int)'undefinedreferenceto'cv::String::deallocate()'undefinedreferenceto'cv::imread(cv::S......
  • 代码随想录第一天|704.二分查找、27.移除元素
    二分查找对数组的要求有两点:有序无重复元素,若有重复元素则返回的元素下标不唯一边界条件是while(left<=right)代码其实是很好理解的点击查看代码classSolution{public:intsearch(vector<int>&nums,inttarget){intlength=nums.size();......
  • 对话无服务器专家 Luca Mezzalira:你真的为 Serverless × AI 做好准备了吗?
    无服务器架构是当下云计算领域最热门的趋势之一。据统计,只有35%的技术人员还没有使用无服务器平台,越来越多的企业出于降低成本、简化运维、加快产品上市速度等原因选择转向无服务器架构。那么,开发人员该如何转变自己的开发方式以适应和充分利用无服务器架构,在业务快速变化的情况......
  • 【剑指Offer】42、和为S的两个数字
    【剑指Offer】42、和为S的两个数字题目描述:输入一个递增排序的数组和一个数字S,在数组中查找两个数,使得他们的和正好是S,如果有多对数字的和等于S,输出两个数的乘积最小的。输出描述:对应每个测试案例,输出两个数,小的先输出。解题思路:对于本题,比上一题简单一些。看到题目,我们的第......
  • Kafka快速实战以及基本原理详解
     这一部分主要是接触Kafka,并熟悉Kafka的使用方式。快速熟练的搭建kafka服务,对于快速验证一些基于Kafka的解决方案,也是非常有用的。一、Kafka介绍​ChatGPT对于ApacheKafka的介绍:ApacheKafka是一个分布式流处理平台,最初由LinkedIn开发并于2011年开源。它主要用于解决大规模......
  • 哈哈哈哈补充快捷键截图
        ......
  • 【DBN回归预测】基于麻雀算法优化深度置信网络SSA-DBN实现数据回归多输出预测附matlab
    ✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。......
  • 多元时间序列 | Matlab粒子群算法优化深度置信网络(PSO-DBN)多变量时间序列预测
    ✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。......