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

建设中英文网站网站书店建设背景

建设中英文网站,网站书店建设背景,做网站公司汉狮团队,联通公网ip申请 做网站滚动表格封装 我们先设定接收的参数 需要表头内容columns,表格数据data,需要currentSlides来控制当前页展示几行 const props defineProps({// 表头内容columns: {type: Array,default: () > [],required: true,},// 表格数据data: {type: Array,d…
滚动表格封装
  1. 我们先设定接收的参数
    需要表头内容columns,表格数据data,需要currentSlides来控制当前页展示几行
const props = defineProps({// 表头内容columns: {type: Array,default: () => [],required: true,},// 表格数据data: {type: Array,default: () => [],},// 当前一页显示几行,超过几行开始滚动currentSlides: {type: Number,default: 5}
});
  1. 写好表格基本样式(这个不通用,可根据需求自行调整)
  2. 表格通常会有操作列,那么我们通过slot来实现,传递当前行的数据item,提供给点击事件
<slot v-if="props.columns[index].slot" :name="props.columns[index].name" :item="item"  />
  1. 封转滚动文字组件,文字超出则滚动显示
    详情可参考另一篇文章戳这里
<HorseRaceLamp:width="props.columns[index].width"font="14px AppleSystemUIFont":text="item[val]":speed="((item[val] && item[val].length) ? item[val].length : 1) * 0.5"
/>

表格完整代码如下:

<template><div class="table"><div class="row thead"><div v-for="item in props.columns" :key="item.name" :style="{ width: `${item.width}px` }">{{ item.label }}</div></div><div class="tbody"><Swiper :modules="modules" :autoplay="swiperOption.autoplay" direction="vertical" :slides-per-view="currentSlides" :space-between="11"><SwiperSlide v-for="(item, ind) in props.data" :key="ind" class="row"><template v-for="(val, index) in columnKeys"><slot v-if="props.columns[index].slot" :name="props.columns[index].name" :item="item"  /><div :title="item[val]" v-else :key="`${index}${val}`" :style="{ width: `${props.columns[index].width}px` }"><HorseRaceLamp:width="props.columns[index].width"font="14px AppleSystemUIFont":text="item[val]":speed="((item[val] && item[val].length) ? item[val].length : 1) * 0.5"/></div></template></SwiperSlide></Swiper></div></div>
</template><script setup>
import { ref, reactive } from 'vue';
import { Swiper, SwiperSlide } from "swiper/vue";
import { Autoplay } from "swiper";
import "swiper/css";
import HorseRaceLamp from '@/components/HorseRaceLamp.vue';const modules = [Autoplay];
const swiperOption = reactive({autoplay: {delay: 3000,disableOnInteraction: false,pauseOnMouseEnter: true,},
});const props = defineProps({// 表头内容columns: {type: Array,default: () => [],required: true,},// 表格数据data: {type: Array,default: () => [],},// 当前一页显示几行,超过几行开始滚动currentSlides: {type: Number,default: 5}
});
const columnKeys = ref([]);columnKeys.value = props.columns.map((item) => item.name);
</script><style lang="scss" scoped>
.table {width: 100%;height: 100%;color: #fff;font-size: 14PX;font-family: AppleSystemUIFont;.thead {background-color: rgb(21 77 160 / 20%);&.row {color: rgba(212, 237, 253, 1);font-size: 12PX;}}.row {display: flex;align-items: center;height: 28PX;padding: 0 30PX;> div {overflow: hidden;width: 100%;margin-right: 10PX;text-align: center;text-overflow: ellipsis;white-space: nowrap;&:nth-last-of-type(1) {margin-right: 0;}}}.swiper {width: 100%;height: 100%;}.tbody {box-sizing: border-box;width: 100%;height: calc(100% - 28PX);padding-top: 11PX;.row {position: relative;display: flex;align-items: center;cursor: pointer;}}
}
</style>

使用方式:

  • 需要给Table组件包裹一个父元素,自定义设置其宽高
<div class="content"><Table :columns="columns" :data="tableData" :currentSlides="6"><template #handler="{ item }"><div class="btn" @click="close(item)">关闭</div></template></Table></div>
// 需要传递的参数
const tableData = ref([])
const columns = [{ name: 'redRank', label: '红榜', width: 148 },{ name: 'blackRank', label: '黑榜', width: 148 },{ name: 'handler', label: '操作', slot: true },
];
// 自定义slot插槽操作事件
const close = (item) => {console.log(item)
}
  • 设置其宽高
.content {width: 446px;height: 250px;
}
http://www.yayakq.cn/news/395734/

相关文章:

  • html5响应式布局网站php网站开发自学
  • 培训学校网站莱芜网络推广公司排行
  • 动感地带套餐seo费用
  • 厦门高端网站建设公成都网站制作培训多少钱
  • 邯郸网站建设好的公司wordpress-erphpdown
  • 网站如果实现微信支付吗网站开发需求网
  • 菏泽市建设局网站电话网站的服务有哪些
  • 网站策划总结wordpress点赞功能纯代码
  • 做自媒体搬运文章的网站支部品牌建设实施方案
  • 张家口百度免费做网站用discuz做商城网站
  • 网络班级网站建设优化大师apk
  • 高明网站设计收费创意设计图片
  • 怎么查找网站是谁做的网址查询ip解析
  • 青海网站开发建设wordpress标签字段
  • 网站开发制作费用网络营销是什么模式
  • 电商网站开发周期wordpress前端插件
  • 网站建设注意要点网站开发教程收费版
  • wordpress怎么禁google潍坊关键词优化软件
  • 肇庆网站建设cz0758织梦网站模板制作
  • 做年会的网站做网站 租服务器
  • iview可以做门户网站吗网站设计团队分工
  • 长沙建网站一般要多少钱wordpress网址转跳页面插件
  • 网站制作计划书有哪些网站做的比较好
  • 丝绸之路网站建设意义网站建设公司价位
  • seo关键词排名优化app重庆seo优化公司哪家好
  • 湖南住房和城乡建设网站wordpress 文章添加字段
  • 网站建设需要步骤wordpress网站不显示系列
  • 有名的wordpress网站网站建设解决
  • 手机网站设计图标qq是哪个公司
  • 拓吧网站wordpress自动采集软件