【APP VTable】和市面上的 Table 组件一样,都是接收表格[] 以及数据源[]

博主:_LJaXi Or 東方幻想郷

专栏: uni-app | 小程序开发

开发工具:HBuilderX

这里写目录标题

表格组件

html 复制代码
<template>
	<view class="scroll-table-wrapper">
		<view class="scroll-table-container">
			<table class="scroll-table">
				<thead>
					<tr>
						<th v-for="(item, index) in columns" :key="index">
							{{ item.title }}
						</th>
					</tr>
				</thead>
				<!-- 表格内容 -->
				<tbody v-if="dataSource.length > 0">
					<tr v-for="(row, rowIndex) in dataSource" :key="rowIndex">
						<td v-for="(cell, cellIndex) in columns" :key="cellIndex">
							<view v-if="cell.title !== '操作'"
								:style="{'width': cell.width, 'white-space': cell.width ? 'normal' : 'nowrap', 'text-align': 'center'}"
								@click="handleArrowClick(row, cell, type)">
								{{ row[cell.dataIndex] || '' }}
							</view>
							<view v-else>
								<button @click="handleButtonClick(row)" class="op-after-0">{{operateTitle}}</button>
							</view>
						</td>
					</tr>
				</tbody>
				<tbody v-else>
					<tr style="text-align: center;">
						<td :colspan="columns.length">暂无数据</td>
					</tr>
				</tbody>
			</table>
		</view>
	</view>
</template>

<script>
	export default {
		/**
		 * @author _LJaXi
		 * @columns 表头内容
		 * @dataSource 表格数据源
		 * @operateTitle 操作按钮title
		 * @updatehandleOperate 操作栏按钮获取row
		 * @updateshow 单击单元格获取row
		 */
		props: {
			columns: {
				type: Array,
				default: []
			},
			dataSource: {
				type: Array,
				default: []
			},
			// 状态
			type: {
				type: String,
				default: ''
			},
			operateTitle: {
				type: String,
				default: '操作'
			}
		},
		methods: {
			handleArrowClick(item, type) {
				this.$emit('update:show', {
					item,
					type: this.type
				})
			},
			handleButtonClick(item) {
				this.$emit('update:handleOperate', {
					item
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	@import url('index.less');
</style>

USE

html 复制代码
<VTable 
	:columns="maintenanceFeedbackTableData" 
	:dataSource="tableData"
	@update:show="handleShow" 
	@update:handleOperate="handleOperate" 
/>

总之这个表格和市面上的没有什么不同,都是自适应的,这个我是在APP里面写的一个表格,不知道为什么APP会让写表格...

相关推荐
2501_9159090630 分钟前
iOS 上架 App Store 后推送收不到,APNs 证书和生产沙盒环境排查
android·小程序·https·uni-app·iphone·webview
徐同保5 小时前
模板里的图标组件找不到定义?聊聊 @tabler/icons-vue 与自动导入
前端·javascript·vue.js
橙光成长6 小时前
GameScrcpy:不装模拟器,用键鼠手柄和 TypeScript 脚本接管你的安卓手游
android·javascript·typescript·开源·1024程序员节
SEO_juper8 小时前
PHP 站内搜索词分析器:从买家搜的词里,挖出内容缺口
前端·javascript·node.js·json·1024程序员节
2501_915921438 小时前
iOS 上架 App Store 常见 ITMS 报错排查,哪些需要修改哪些是警告
android·ios·小程序·https·uni-app·iphone·webview
AI开源软件9 小时前
SpringBoot多系统同步:别让“同名数据”变成“同一条数据”
vue.js·spring boot·企业管理·mdm
code2cat9 小时前
Vue与React Native任务验收:断网改了标题,重新联网后该看到什么?
vue.js·react native·react.js
FYKJ_201010 小时前
springboot网上汽车租赁系统93523-计算机毕业设计、课程设计
java·vue.js·spring boot·后端·python·汽车·课程设计
AI开源软件1 天前
用MQTT跑通一台模拟设备:看懂IoT产品、物模型和告警
java·vue.js·spring boot·物联网·mqtt·iot·企业管理
橙光成长1 天前
12 万 Star 的 browser-use:用 600 行 CDP 直连,把“让 AI 上网”从视觉猜测变成坐标点击
人工智能·开源·1024程序员节