您的位置:首页 > 健康 > 美食 > 青浦人才网官网_站长工具劲爆_营销网站定制公司_链接买卖是什么意思

青浦人才网官网_站长工具劲爆_营销网站定制公司_链接买卖是什么意思

2024/12/23 1:11:43 来源:https://blog.csdn.net/2301_79568779/article/details/142765882  浏览:    关键词:青浦人才网官网_站长工具劲爆_营销网站定制公司_链接买卖是什么意思
青浦人才网官网_站长工具劲爆_营销网站定制公司_链接买卖是什么意思

一、默认插槽

<template><div class='father'><h3>父组件</h3><div class="content"><Category title='热门游戏列表'><ul><li v-for='item in games' :key='item.id'>{{item.name}}</li></ul></Category><Category title='今日美食城市'><img :src="imgUrl" alt=""></Category><Category title='今日影视推荐'><video :src="videoUrl" controls></video></Category></div></div>
</template>
<script setup>
import  Category from './Category.vue'
import {ref,reactive} from 'vue'
let games=reactive([{id:'afdddwet1',name:'4399小游戏'},{id:'afdddwet2',name:'网页小游戏'},{id:'afdddwet3',name:'手机小游戏'},{id:'afdddwet4',name:'小游戏'}
])
let imgUrl=ref('https://p0.ssl.qhimgs1.com/sdr/400__/t0473991f73e7e7f1be.jpg')
let videoUrl = ref('http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4')
</script>
<style scoped lang='scss'>
.father{width: 100%;height: 100%;padding:20px;.content{display: flex;justify-content: space-evenly;}img,video{width: 100%;}
}
</style><template><div class="category"><h4>{{title}}</h4><slot></slot></div>
</template>
<script setup>
defineProps(['title'])
</script>
<style scoped lang='scss'>
.category{background-color: skyblue;border-radius: 10px;box-shadow: 0 0 10px;padding: 10px;width: 200px;height: 300px;h4{background-color: orange;text-align: center;font-size: 20px;}
}
</style>

二、具名插槽

<template><div class='father'><h3>父组件</h3><div class="content"><Category><template v-slot:s1><h4>热门游戏列表</h4></template><template v-slot:s2><ul><li v-for='item in games' :key='item.id'>{{item.name}}</li></ul></template></Category><Category><template v-slot:s1><h4>今日美食城市</h4></template><template v-slot:s2><img :src="imgUrl" alt=""></template></Category><Category><template #s1><h4>今日影视推荐</h4></template><template #s2><video :src="videoUrl" controls></video></template></Category></div></div>
</template>
<script setup>
import  Category from './Category.vue'
import {ref,reactive} from 'vue'
let games=reactive([{id:'afdddwet1',name:'4399小游戏'},{id:'afdddwet2',name:'网页小游戏'},{id:'afdddwet3',name:'手机小游戏'},{id:'afdddwet4',name:'小游戏'}
])
let imgUrl=ref('https://p0.ssl.qhimgs1.com/sdr/400__/t0473991f73e7e7f1be.jpg')
let videoUrl = ref('http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4')
</script>
<style scoped lang='scss'>
.father{width: 100%;height: 100%;padding:20px;.content{display: flex;justify-content: space-evenly;}img,video{width: 100%;}h4{background-color: orange;text-align: center;font-size: 20px;}
}
</style><template><div class="category"><slot name='s1'></slot><slot name='s2'></slot></div>
</template>
<script setup>
</script>
<style scoped lang='scss'>
.category{background-color: skyblue;border-radius: 10px;box-shadow: 0 0 10px;padding: 10px;width: 200px;height: 300px;
}
</style>

三、作用域插槽

数据由子组件维护,页面结构由父组件维护

<template><div class='father'><h3>父组件</h3><div class="content"><Games><template v-slot='params'><ul><li v-for='item in params.youxi' :key='item.id'>{{item.name}}</li></ul></template></Games><Games><template v-slot:default='params'><ol><li v-for='item in params.youxi' :key='item.id'>{{item.name}}</li></ol></template></Games><Games><template #default='{youxi}'><h3 v-for='item in youxi' :key='item.id'>{{item.name}}</h3></template></Games></div></div>
</template>
<script setup>
import  Games from './Games.vue'
</script>
<style scoped lang='scss'>
.father{width: 100%;height: 100%;padding:20px;.content{display: flex;justify-content: space-evenly;}img,video{width: 100%;}ul,ol{padding:10px;}
}
</style><template><div class="games"><h4>热门游戏列表</h4><slot :youxi='games'></slot></div>
</template>
<script setup>
import {ref,reactive} from 'vue'
let games=reactive([{id:'afdddwet1',name:'4399小游戏'},{id:'afdddwet2',name:'网页小游戏'},{id:'afdddwet3',name:'手机小游戏'},{id:'afdddwet4',name:'小游戏'}
])
</script>
<style scoped lang='scss'>
.games{background-color: skyblue;border-radius: 10px;box-shadow: 0 0 10px;padding: 10px;width: 200px;height: 300px;h4{background-color: orange;text-align: center;font-size: 20px;}
}
</style>

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com