vue+ts+element 表格添加下拉框和input选项

16 篇文章 0 订阅
<el-table
						:data="tableData"
						class="tb-edit"
						:header-cell-style="{ background: '#b4d8df' }"
						style="width: 100%"
						height="600px"
						highlight-current-row
						@row-click="handleCurrentChange"
					>
						<el-table-column label="名称" width="180">
							<template scope="scope">
								<el-select size="small" v-model="scope.row.date" placeholder="请选择">
									<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
								</el-select>
								<span>{{ scope.row.date }}</span>
							</template>
						</el-table-column>
						<el-table-column label="类型" width="180">
							<template scope="scope">
								<el-input size="small" v-model="scope.row.name" placeholder="请输入内容" @change="handleEdit(scope.$index, scope.row)"></el-input>
								<span>{{ scope.row.name }}</span>
							</template>
						</el-table-column>
						<el-table-column prop="address" label="原格式">
							<template scope="scope">
								<el-input size="small" v-model="scope.row.address" placeholder="请输入内容" @change="handleEdit(scope.$index, scope.row)"></el-input>
								<span>{{ scope.row.address }}</span>
							</template>
						</el-table-column>
						<el-table-column prop="address" label="长度">
							<template scope="scope">
								<el-input size="small" v-model="scope.row.address" placeholder="请输入内容" @change="handleEdit(scope.$index, scope.row)"></el-input>
								<span>{{ scope.row.address }}</span>
							</template>
						</el-table-column>
						<el-table-column prop="address" label="精度">
							<template scope="scope">
								<el-input size="small" v-model="scope.row.address" placeholder="请输入内容" @change="handleEdit(scope.$index, scope.row)"></el-input>
								<span>{{ scope.row.address }}</span>
							</template>
						</el-table-column>
					</el-table>
tableData: Array<Object> = [
		{
			date: '2016-05-02',
			name: '王小虎',
			address: '上海市普陀区金沙江路 1518 弄'
		},
		{
			date: '2016-05-04',
			name: '王小虎',
			address: '上海市普陀区金沙江路 1517 弄'
		},
		{
			date: '2016-05-01',
			name: '王小虎',
			address: '上海市普陀区金沙江路 1519 弄'
		},
		{
			date: '2016-05-03',
			name: '王小虎',
			address: '上海市普陀区金沙江路 1516 弄'
		},
		{
			date: '2016-05-04',
			name: '王小虎',
			address: '上海市普陀区金沙江路 1517 弄'
		},
		{
			date: '2016-05-01',
			name: '王小虎',
			address: '上海市普陀区金沙江路 1519 弄'
		},
		{
			date: '2016-05-03',
			name: '王小虎',
			address: '上海市普陀区金沙江路 1516 弄'
		},
		{
			date: '2016-05-04',
			name: '王小虎',
			address: '上海市普陀区金沙江路 1517 弄'
		},
		{
			date: '2016-05-01',
			name: '王小虎',
			address: '上海市普陀区金沙江路 1519 弄'
		},
		{
			date: '2016-05-03',
			name: '王小虎',
			address: '上海市普陀区金沙江路 1516 弄'
		}
	]

handleCurrentChange(row, event, column) {
		console.log(row, event, column, event.currentTarget)
	}
	handleEdit(index, row) {
		console.log(index, row)
	}
.tb-edit .el-input {
			display: none;
		}
		.tb-edit .el-select {
			display: none;
		}
		.tb-edit .current-row .el-select {
			display: block;
		}
		.tb-edit .current-row .el-select + span {
			display: none;
		}
		.tb-edit .current-row .el-input {
			display: block;
		}
		.tb-edit .current-row .el-input + span {
			display: none;
		}

效果图展示

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值