el-input 加在el-tabs后
时间: 2023-07-05 17:08:43 浏览: 162
如果你希望将 `el-input` 放置在 `el-tabs` 组件的后面,可以按照以下步骤进行:
1. 在 `el-tabs` 组件外部包装一层 `div` 元素,将 `el-tabs` 和 `el-input` 放置在这个 `div` 元素内部,例如:
```html
<div class="wrapper">
<el-tabs>
<!-- el-tabs 的内容 -->
</el-tabs>
<el-input></el-input>
</div>
```
2. 使用 CSS 样式将 `el-input` 元素的位置设置为相对于 `el-tabs` 元素的下面,例如:
```css
.wrapper {
position: relative;
}
.el-input {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
}
```
这样,`el-input` 就会相对于 `el-tabs` 元素的下方进行定位,达到将 `el-input` 放置在 `el-tabs` 后面的效果。
相关问题
将以下vue+element ui代码转换成纯html+element ui代码:<template> <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick"> <el-tab-pane label="User" name="first"> <el-table :data="filterTableData" style="width: 100%"> <el-table-column label="Date" prop="date" /> <el-table-column label="Name" prop="name" /> <el-table-column align="right"> <template #header> <el-input v-model="search" size="small" placeholder="Type to search" /> </template> <template #default="scope"> <el-button size="small" @click="handleEdit(scope.$index, scope.row)" >Edit</el-button > <el-button size="small" type="danger" @click="handleDelete(scope.$index, scope.row)" >Delete</el-button > </template> </el-table-column> </el-table> </el-tab-pane> <el-tab-pane label="Config" name="second"> <el-table :data="filterTableData" style="width: 100%"> <el-table-column label="Date" prop="date" /> <el-table-column label="Name" prop="name" /> <el-table-column align="right"> <template #header> <el-input v-model="search" size="small" placeholder="Type to search" /> </template> <template #default="scope"> <el-button size="small" @click="handleEdit(scope.$index, scope.row)" >Edit</el-button > <el-button size="small" type="danger" @click="handleDelete(scope.$index, scope.row)" >Delete</el-button > </template> </el-table-column> </el-table></el-tab-pane> <el-tab-pane label="Role" name="third"> <el-table :data="filterTableData" style="width: 100%"> <el-table-column label="Date" prop="date" /> <el-table-column label="Name" prop="name" /> <el-table-column align="right"> <template #header> <el-input v-model="search" size="small" placeholder="Type to search" /> </template> <template #default="scope"> <el-button size="small" @click="handleEdit(scope.$index, scope.row)" >Edit</el-button > <el-button size="small" type="danger" @click="handleDelete(scope.$index, scope.row)" >Delete</el-button > </template> </el-table-column> </el-table></el-tab-pane> <el-tab-pane label="Task" name="fourth"> <el-table :data="filterTableData" style="width: 100%"> <el-table-column label="Date" prop="date" /> <el-table-column label="Name" prop="name" /> <el-table-column align="right"> <template #header> <el-input v-model="search" size="small" placeholder="Type to search" /> </template> <template #default="scope"> <el-button size="small" @click="handleEdit(scope.$index, scope.row)" >Edit</el-button > <el-button size="small" type="danger" @click="handleDelete(scope.$index, scope.row)" >Delete</el-button > </template> </el-table-column> </el-table></el-tab-pane> </el-tabs> </template> <script lang="ts" setup> import { computed, ref } from 'vue' interface User { date: string name: string address: string } const search = ref('') const filterTableData = computed(() => tableData.filter( (data) => !search.value || data.name.toLowerCase().includes(search.value.toLowerCase()) ) ) const handleEdit = (index: number, row: User) => { console.log(index, row) } const handleDelete = (index: number, row: User) => { console.log(index, row) } const tableData: User[] = [ { date: '2016-05-03', name: 'Tom', address: 'No. 189, Grove St, Los Angeles', }, { date: '2016-05-02', name: 'John', address: 'No. 189, Grove St, Los Angeles', }, { date: '2016-05-04', name: 'Morgan', address: 'No. 189, Grove St, Los Angeles', }, { date: '2016-05-01', name: 'Jessy', address: 'No. 189, Grove St, Los Angeles', }, ] </script> <style> .demo-tabs > .el-tabs__content { padding: 32px; color: #6b778c; font-size: 32px; font-weight: 600; } </style>
以下是转换后的纯HTML+Element UI代码:
```html
<div class="demo-tabs el-tabs">
<div class="el-tabs__header">
<div class="el-tabs__nav-wrap">
<div role="tab" aria-controls="pane-first" :aria-selected="activeName==='first' ? 'true' : 'false'" class="el-tabs__item" :class="{ 'is-active': activeName==='first' }" @click="activeName='first'">User</div>
<div role="tab" aria-controls="pane-second" :aria-selected="activeName==='second' ? 'true' : 'false'" class="el-tabs__item" :class="{ 'is-active': activeName==='second' }" @click="activeName='second'">Config</div>
<div role="tab" aria-controls="pane-third" :aria-selected="activeName==='third' ? 'true' : 'false'" class="el-tabs__item" :class="{ 'is-active': activeName==='third' }" @click="activeName='third'">Role</div>
<div role="tab" aria-controls="pane-fourth" :aria-selected="activeName==='fourth' ? 'true' : 'false'" class="el-tabs__item" :class="{ 'is-active': activeName==='fourth' }" @click="activeName='fourth'">Task</div>
</div>
</div>
<div class="el-tabs__content">
<div role="tabpanel" aria-hidden="false" id="pane-first" class="el-tab-pane" :class="{ 'is-active': activeName==='first' }">
<table class="el-table" style="width: 100%">
<thead class="el-table__header">
<tr>
<th class="el-table_1_column_1">Date</th>
<th class="el-table_1_column_2">Name</th>
<th class="el-table_1_column_3">Operation</th>
</tr>
</thead>
<tbody class="el-table__body">
<tr v-for="(item, index) in filterTableData" :key="index">
<td>{{ item.date }}</td>
<td>{{ item.name }}</td>
<td class="el-table_1_column_3">
<button class="el-button el-button--small" @click="handleEdit(index, item)">Edit</button>
<button class="el-button el-button--small el-button--danger" @click="handleDelete(index, item)">Delete</button>
</td>
</tr>
</tbody>
</table>
</div>
<div role="tabpanel" aria-hidden="true" id="pane-second" class="el-tab-pane" :class="{ 'is-active': activeName==='second' }">
<table class="el-table" style="width: 100%">
<thead class="el-table__header">
<tr>
<th class="el-table_2_column_1">Date</th>
<th class="el-table_2_column_2">Name</th>
<th class="el-table_2_column_3">Operation</th>
</tr>
</thead>
<tbody class="el-table__body">
<tr v-for="(item, index) in filterTableData" :key="index">
<td>{{ item.date }}</td>
<td>{{ item.name }}</td>
<td class="el-table_2_column_3">
<button class="el-button el-button--small" @click="handleEdit(index, item)">Edit</button>
<button class="el-button el-button--small el-button--danger" @click="handleDelete(index, item)">Delete</button>
</td>
</tr>
</tbody>
</table>
</div>
<div role="tabpanel" aria-hidden="true" id="pane-third" class="el-tab-pane" :class="{ 'is-active': activeName==='third' }">
<table class="el-table" style="width: 100%">
<thead class="el-table__header">
<tr>
<th class="el-table_3_column_1">Date</th>
<th class="el-table_3_column_2">Name</th>
<th class="el-table_3_column_3">Operation</th>
</tr>
</thead>
<tbody class="el-table__body">
<tr v-for="(item, index) in filterTableData" :key="index">
<td>{{ item.date }}</td>
<td>{{ item.name }}</td>
<td class="el-table_3_column_3">
<button class="el-button el-button--small" @click="handleEdit(index, item)">Edit</button>
<button class="el-button el-button--small el-button--danger" @click="handleDelete(index, item)">Delete</button>
</td>
</tr>
</tbody>
</table>
</div>
<div role="tabpanel" aria-hidden="true" id="pane-fourth" class="el-tab-pane" :class="{ 'is-active': activeName==='fourth' }">
<table class="el-table" style="width: 100%">
<thead class="el-table__header">
<tr>
<th class="el-table_4_column_1">Date</th>
<th class="el-table_4_column_2">Name</th>
<th class="el-table_4_column_3">Operation</th>
</tr>
</thead>
<tbody class="el-table__body">
<tr v-for="(item, index) in filterTableData" :key="index">
<td>{{ item.date }}</td>
<td>{{ item.name }}</td>
<td class="el-table_4_column_3">
<button class="el-button el-button--small" @click="handleEdit(index, item)">Edit</button>
<button class="el-button el-button--small el-button--danger" @click="handleDelete(index, item)">Delete</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
```
需要注意的是,Element UI的CSS样式需要在HTML文件中引入。此外,上述代码中的`activeName`、`search`、`filterTableData`、`handleEdit`和`handleDelete`需要在JavaScript中定义和实现。
帮我用vue+element-ui封装个el-tabs 下分块包含 el-form的组件
好的,我可以为您提供代码示例,实现用 Vue Element-UI 封装一个带有分块、包含 el-form 的 el-tabs 组件。代码如下:
```vue
<template>
<div class="xs-tabs-form-container">
<el-tabs v-model="activeTab" style="height: 100%">
<el-tab-pane :label="pane.label" :key="index" v-for="(pane, index) in tabPanes">
<el-form :model="formData" :rules="formRules" ref="xsForm" label-width="100px">
<el-row :gutter="20" v-for="(element, rowIndex) in pane.elements" :key="rowIndex">
<el-col :span="12" v-for="(item, colIndex) in element" :key="colIndex">
<el-form-item :label="item.label" :prop="item.prop">
<template v-if="item.custom">
<slot :name="item.prop" :item="item"></slot>
</template>
<template v-else>
<el-input v-model="formData[item.prop]"></el-input>
</template>
</el-form-item>
</el-col>
</el-row>
<el-form-item>
<el-button type="primary" @click="submitForm">提交</el-button>
</el-form-item>
</el-form>
</el-tab-pane>
</el-tabs>
</div>
</template>
<script>
export default {
name: "XsTabsForm",
props: {
tabPanes: {
type: Array, // [{label: 'Tab 1', elements: [[{label: 'Field 1', prop: 'field1'}]]}]
required: true
},
rules: {
type: Object, // {field1: [{required: true, message: '不能为空', trigger: 'blur'}]}
required: true
}
},
data() {
return {
activeTab: 0,
formData: {}
};
},
computed: {
formRules() {
const rules = {};
for (let key of Object.keys(this.formData)) {
if (this.rules[key]) {
rules[key] = this.rules[key];
}
}
return rules;
}
},
methods: {
submitForm() {
this.$refs['xsForm'].validate((valid) => {
if (valid) {
this.$emit('submit-form', this.formData);
} else {
this.$message.error('表单校验失败,请检查输入');
}
});
}
}
};
</script>
<style scoped>
.xs-tabs-form-container {
height: 100%;
}
</style>
```
您可以通过 `tabPanes` 和 `rules` 两个参数传递组件中的标签页面和表单控制参数。每个标签页面可以包含多个行,每行包含多个表单项。可以选择使用默认的输入框,也可以通过 `item.custom` 参数自定义表单控件。您可以在 `submit-form` 事件中获取表单数据。
阅读全文