el-table-column 怎么实现可以点击并且跳转到新的路由页面
时间: 2023-04-09 21:03:41 浏览: 186
el-table-column 可以通过设置 scoped-slot 来实现点击并跳转到新的路由页面。具体实现可以参考以下代码:
<el-table-column label="操作">
<template slot-scope="scope">
<router-link :to="'/detail/' + scope.row.id">查看详情</router-link>
</template>
</el-table-column>
其中,scoped-slot 用于自定义列的内容,通过 router-link 组件来实现路由跳转。在 to 属性中,可以通过拼接参数来传递需要跳转的路由地址。
相关问题
el-table-column设置下划线蓝色点击跳转
在el-table-column中设置下划线蓝色点击跳转,可以通过使用slot-scope来自定义单元格的内容,并在其中添加超链接。具体步骤如下:
1. 在el-table-column中添加slot-scope属性,指定一个作用域插槽。
2. 在作用域插槽中,使用a标签来创建超链接,并设置样式为下划线蓝色。
3. 使用v-bind:href绑定超链接的目标地址。
以下是一个示例代码:
```html
<el-table-column label="跳转链接" prop="link">
<template slot-scope="scope">
<a :href="scope.row.link" style="text-decoration: underline; color: blue;">
{{ scope.row.link }}
</a>
</template>
</el-table-column>
```
在上述代码中,我们使用了作用域插槽来获取每个单元格的数据,并将其作为超链接的目标地址。同时,我们设置了超链接的样式为下划线蓝色。
el-table-column点击单元格跳转
根据提供的两个引用,el-table-column点击单元格跳转的实现方式如下:
1. 点击单元格跳转到新页面
```html
<el-table :data="allData">
<el-table-column prop="tel" label="联系电话" align="center">
<template slot-scope="scope">
<div>
<a href="javascript:;" @click="goEnviro">{{scope.row.tel}}</a>
</div>
</template>
</el-table-column>
</el-table>
<script>
export default {
data() {
return {
allData: [
{ name: "", classify: "", tel: "", update: "", fileType: "", },
]
}
},
methods: {
goEnviro() {
this.$router.push('/filetext/findfile')
}
}
}
</script>
```
2. 点击单元格跳转到新页面并传递参数
```html
<el-table ref="dataTable" :data="userList">
<el-table-column prop="username" label="用户账号">
<template slot-scope="scope">
<el-link type="success" v-on:click="cellclick(scope.row)">{{scope.row.username}}</el-link>
</template>
</el-table-column>
</el-table>
<script>
export default {
data() {
return {
userList: []
}
},
methods: {
cellclick(row) {
this.$router.push({
path: '/user/detail',
query: {
id: row.id
}
})
}
}
}
</script>
```