vue中完美实现多组件动态调用渲染
2023-09-14 09:14:32 时间
<template>
<div class="top">
<div class="top_div">
<div style="background-color:coral;">
<img style="width: 50px;height: 50px" src="../assets/logo.png">
</div>
<div class="top_b" style="background-color:lightblue;">
<div v-for='(item,index) in arrl'
:class='{itemhover:index===isactivel}'
@click='lfn(index)'>
{{item}}
</div>
</div>
</div>
<div id="left">
<div class="left_div" style="background-color:coral;">
{{arrl[isactivel]}}
</div>
<div class="center_div" style="background-color:lightblue;">
<div class="center_div_header">
<div v-for='(item,index) in arr[isactivel]'
:class='{itemhover:index===isactive}'
@click='fn(index)'>
{{item}}
</div>
</div>
<div class="center_div_body">
<div v-show=show_list[index] v-for='(item,index) in arr[isactivel]'
:class='{itemdisplay :index===isactive}'>
<component :is="currentView"></component>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import CommentSetting from './CommentSetting'
export default {
name: 'ting',
table_title: [16, 17, 18, 19],
data () {
return {
itemhoverindex: null,
isactive: 0,
isactivel: 0,
isactivell: 0,
arr: [['home','post','archive',"home"],['home','post','archive',"home"],['home','post','archive',"home"],['home','post','archive',"home"]],
arrl: ['111','222','333','444'],
show_list: [1,0,0,0],
cindex:0,
table_list:[['home','post','archive',"home"],['home','post','archive',"home"],['home','post','archive',"home"],['home','post','archive',"home"]],
}
},
methods: {
lfn: function (index) {
this.show_list=[0,0,0,0]
this.show_list[0]=1
this.isactive=0
this.isactivel = index
console.log(this.isactivel,this.isactive)
},
fn: function (index) {
this.show_list=[0,0,0,0]
this.show_list[index]=1
this.isactive = index
}
},
components: {
'home':CommentSetting,
"post":CommentSetting,
"archive":CommentSetting
},
computed:{
currentView(){
return this.table_list[this.isactivel][this.isactive];
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.top {
border: 0;
display: flex;
flex-direction: row;
}
.top .top_div {
border: 0;
display: flex;
flex-direction: column;
}
.top .top_div div {
width: 150px;
height: 50px;
}
#left {
border: 0;
display: flex;
flex-direction: column;
}
.top #left .left_div{
height:50px;
}
.top #left .center_div {
height: 800px;
width: 800px;
display: flex;
flex-direction: column;
}
.top #left .center_div .center_div_body {
width: auto;
height: 800px;
}
.top #left .center_div .center_div_header {
width: auto;
display: flex;
flex-direction: row;
}
.top #left .center_div .center_div_header div {
width: 80px;
background-color: salmon;
}
.top .top_div .top_b {
height: auto;
border: 0;
display: flex;
flex-direction: column;
}
.top .top_div .top_b div {
width: 150px;
background-color: darkgray;
}
.itemhover {
background-color: fuchsia !important;
color: cornflowerblue !important;
height: 50px;
}
.itemdisplay {
display: block;
height: 800px;
background-color: burlywood;
}
</style>
相关文章
- vue父组件传字符串到子组件不需要写 v-bind 绑定或语法糖 :
- vue 使用路由重复跳转同一页面
- Vue的简单入门
- vue.js3.2.20: 在打包时取消生成.map文件
- Vue.js 组件编码规范
- 使用Karma、Mocha实现vue单元测试
- EasyDSS高性能RTMP、HLS(m3u8)、HTTP-FLV、RTSP流媒体服务器web前端:vue组件之间的传值,父组件向子组件传值
- vue中8种组件通信方式, 值得收藏!
- vue watch的this 到底是什么?
- vue.js3: 数字的进制转换(vue@3.2.37)
- vue全局组件与局部组件
- vue父子组件传值:子修改父
- Vue入门教程:node安装vue命令行工具及启动项目
- vue商城项目开发:封装banner组件、组件参数传递
- 声纹可视化工具:wavesurfer.js---在Vue中使用音频声纹可视化插件wavesurfer.js【已封装成组件有完整demo实例附完整代码】
- vue中使用百度地图,悬浮窗搜索功能
- CDN方式使用Vue组件通信
- Vue学习之--------深入理解Vuex之多组件共享数据(2022/9/4)
- Vue中组件化编码使用、实现组件之间的参数传递(实战练习二)
- Vue中组件化编码使用(实战练习一)
- Vue学习之--------组件嵌套以及VueComponent的讲解(代码实现)(2022/7/23)
- Springboot+Vue实现将图片和表单一起提交到后端,同时将图片地址保存到数据库、再次将存储的图片展示到前端vue页面
- 基于 Vue.js 的移动端组件库mint-ui实现无限滚动加载更多
- Vue组件化开发
- 098:vue+openlayers的set extent 和 fit extent功能(示例代码)
- 016:vue+openlayer修改自定义地图版权信息( 示例代码 )
- vue-tour快速入门:VUE项目中如何使用vue-tour新手引导指引插件?怎样使用?包含具体实例
- 【Vue笔记】Vue中默认插槽slot、具名插槽slot、自定义组件的v-model属性的使用
- Vue的基本组件1(show,bind,on,if)