vue el-table中跳转新网页 demo

本文介绍了在前端开发中实现购买链接展示的两种方法:一种是直接使用a标签进行链接跳转;另一种是通过按钮点击触发跳转。这两种方法都能实现在新标签页中打开链接的功能。

 方式一:

<el-table-column prop="shopUrl" label="购买地址" align="left" width="220">
          <template slot-scope="scope">
             <a target="_blank" :href="scope.row.shopUrl" style="white-space:nowrap"><u>{{scope.row.shopUrl}}</u></a>
          </template>
        </el-table-column>

target="_blank" 标签打开新网页

方式二:

<el-table-column prop="shopUrl" label="购买地址" align="left" width="220">
          <template slot-scope="scope">
           <el-button size="mini" type="text" style="width: 120px;" @click="jumpView(scope.row.shopUrl)">
             <span style="white-space:nowrap"><u>{{scope.row.shopUrl}}</u></span>
            </el-button>
          </template>
        </el-table-column>
jumpView(url){//跳转购买网址
      console.log('跳转购买网址=======start:'+url)
      //window.location = url;//当前页跳转新网页
      window.open(url);//打开新网页跳转至新网页
    },

效果:

<!-- * @fenghua: 2401_87008233 3024798541@qq.com * @Date: 2025-09-05 18:56:30 * @LastEditors: 2401_87008233 3024798541@qq.com * @LastEditTime: 2025-09-05 23:04:57 * @FilePath: \NanChange:\Vue代码\hou_tai\src\App.vue * @Description: * * Copyright (c) 2025 by ${fenghua}, All Rights Reserved. --> <script setup lang="ts"> import { ref } from 'vue' import { Search } from '@element-plus/icons-vue' import { tableData } from './comm/ts' import type { ComponentSize } from 'element-plus' const input1 = ref('') import './comm/css.css'; const currentPage4 = ref(4) const pageSize4 = ref(100) const size = ref<ComponentSize>('default') const disabled = ref(false) const parentBorder = ref(false) const handleSizeChange = (val: number) => { console.log(`${val} items per page`) } const handleCurrentChange = (val: number) => { console.log(`current page: ${val}`) } const preserveExpanded = ref(false) </script> <template> <div class="template"> <div class="common-layout"> <el-container> <el-header class="header"> <!-- 左侧输入框 --> <el-input v-model="input1" style="width: 300px" size="large" placeholder="请输入租户名称" :suffix-icon="Search" /> <!-- 右侧建框 --> <el-button type="primary">十 建</el-button> </el-header> <!-- /主题内容 --> <el-main class="zhuti"> <el-table :data="tableData" height="550" style="width: 100%"> <el-table-column prop="date" label="序号" width="100" /> <el-table-column prop="name" label="角色类型" width="180" /> <el-table-column label="用户组状态" width="340" align="center"> <template #default="scope"> <el-switch v-model="scope.row.status" /> </template> </el-table-column> <el-table-column prop="address" label="操作时间" width="280" /> <el-table-column label="操作" width="300" class="tupian"> <template v-slot> <img src="/image/bianji.png" alt="" width="20px" style="margin-right: 30px;"> <img src="/image/qunzu.png" alt="" width="20px" style="margin-right: 30px;"> <img src="/image/zengjia.png" alt="" width="20px" style="margin-right: 30px;"> <img src="/image/shanchu.png" alt="" width="20px" style="margin-right: 30px;"> </template> </el-table-column> <el-table-column :border="parentBorder" :preserve-expanded-content="preserveExpanded" /> </el-table> <!-- 分页器 --> <div class="demo-pagination-block fenyeqi"> <el-pagination background v-model:current-page="currentPage4" v-model:page-size="pageSize4" :page-sizes="[100, 200, 300, 400]" :size="size" :disabled="disabled" layout="total, prev, pager, next, jumper" :total="869" @size-change="handleSizeChange" @current-change="handleCurrentChange" jumper="跳转" /> </div> </el-main> </el-container> </div> </div> </template> <style scoped></style> 修改以上VUE+element代码 (el-button type="primary">十 建</el-button>)做个添加数据,别重做页面
09-07
<template> <div class="layout-container-demo"> <el-container> <!-- 左侧菜单栏 --> <el-aside width="200px"> <el-input v-model="filterText" class="w-60 mb-2" placeholder="Filter keyword" /> <el-tree ref="treeRef" style="max-width: 600px" class="filter-tree" :data="dataList" :props="defaultProps" default-expand-all :filter-node-method="filterNode" /> </el-aside> <!-- 右侧内容区域 --> <el-container direction="vertical"> <!-- 高级查询区域 --> <el-header class="search-header"> <el-form :inline="true" label-position="right"> <el-form-item label="名称"> <el-input v-model="searchForm.name" placeholder="请输入名称" style="width: 150px"/> </el-form-item> <el-form-item label="状态" > <el-select v-model="searchForm.status" placeholder="请选择" style="width: 150px"> <el-option label="启用" value="1" /> <el-option label="禁用" value="0" /> </el-select> </el-form-item> <el-button type="primary" @click="onSubmit">查询</el-button> </el-form> </el-header> <!-- 表格区域 --> <el-main class="table-main"> <el-table :data="tableData" border style="width: 100%"> <el-table-column prop="name" label="姓名" /> <el-table-column prop="age" label="年龄" /> <el-table-column prop="status" label="状态"> <template #default="{ row }"> {{ row.status === '1' ? '启用' : '禁用' }} </template> </el-table-column> </el-table> </el-main> <!-- 分页组件 --> <el-footer height="60px" class="custom-footer"> <el-pagination size="small" background layout="sizes, prev, pager, next" :total="total" v-model:current-page="currentPage" v-model:page-size="pageSize" :page-sizes="[10, 20, 30, 50, 100]" @current-change="handlePageChange" /> </el-footer> </el-container> </el-container> </div> </template> <script> import { ref, watch, onMounted } from 'vue' export default { setup() { const filterText = ref('') const dataList = ref([ { id: 1, label: '菜单1', children: [ { id: 3, label: '菜单1-3', children: [] }, { id: 4, label: '菜单1-4', children: [] } ] }, { id: 2, label: '菜单2', children: [ { id: 5, label: '菜单2-5', children: [] } ] }, ]) const defaultProps = { children: 'children', label: 'label' } const treeRef = ref(null) // 监听 filterText 的变化,并调用树的 filter 方法 watch(filterText, (val) => { if (treeRef.value) { treeRef.value.filter(val) } }) const filterNode = (value, data) => { console.log(data,'11111'); console.log(value,'22222'); if (!value) return true return data.label.includes(value) } const searchForm = ref({ name: '', status: '' }) const tableData = ref([]) const total = ref(0) const currentPage = ref(1) const pageSize = ref(10) const fetchData = () => { // 模拟异步请求,实际应替换为调用接口 setTimeout(() => { tableData.value = [ { name: '张三', age: 25, status: '1' }, { name: '李四', age: 30, status: '0' }, ] total.value = 50 }, 500) } const onSubmit = () => { currentPage.value = 1 fetchData() } const handlePageChange = (page) => { currentPage.value = page fetchData() } onMounted(() => { fetchData() }) return { filterText, dataList, defaultProps, treeRef, filterNode, searchForm, tableData, total, currentPage, pageSize, onSubmit, handlePageChange, } } } </script> <style scoped> .layout-container-demo .el-header { background-color: var(--el-color-primary-light-7); color: var(--el-text-color-primary); padding: 10px 20px; } .layout-container-demo .search-header .el-form { display: flex; flex-wrap: wrap; /* 允许换行 */ align-items: center; } .layout-container-demo .search-header .el-form-item { margin-bottom: 0; /* 去掉默认的 margin-bottom */ margin-right: 10px; /* 增加表单项之间的间距 */ } .layout-container-demo .search-header .el-button { padding: 12px 20px; height: 36px; /* 设置固定高度,和 el-input 保持一致 */ } .layout-container-demo .el-aside { background-color: #fff; } .layout-container-demo .custom-menu { height: 100%; } .layout-container-demo .search-header { background-color: #fff; padding-top: 10px; } .layout-container-demo .table-main { padding: 20px; } .layout-container-demo .custom-footer { display: flex; align-items: right; justify-content: right; } </style> 在管理系统中,一般左边的菜单列表是不变的,右边的内容是一直在变的,怎么做的呢
最新发布
11-18
<template> <el-container class="layout-container-demo" style="height: 500px"> <el-header style="text-align: right; font-size: 12px"> <div class="toolbar"> <el-dropdown> <el-icon style="margin-right: 8px; margin-top: 1px"> <setting /> </el-icon> <template #dropdown> <el-dropdown-menu> <el-dropdown-item @click="logOut()">退出登录</el-dropdown-item> </el-dropdown-menu> </template> </el-dropdown> <span>关宇航</span> </div> </el-header> <el-container> <el-aside width="200px"> <el-scrollbar> <el-menu :default-active="$route.path" class="el-menu-vertical-demo" :router="true"> <template v-for="(item, index) in menuList"> <el-menu-item v-if="isShow(item)" :index="index" :route="item.path">{{ item.label }}</el-menu-item> </template> </el-menu> </el-scrollbar> </el-aside> <el-main> <router-view /> </el-main> </el-container> </el-container> </template> <script setup> import { Menu as IconMenu, Setting } from '@element-plus/icons-vue' import useUserStore from '@/store/modules/user'; import { ElMessage } from 'element-plus' const userStore = useUserStore(); const router = useRouter(); const menuList = ref([]); function isShow(item) { return item?.aaaaa != 'asaf' } onMounted(() => { if (userStore.isLogin()) { setMenu(router.options.routes); } else { ElMessage.error(‘用户未登录,跳转至登录页面’); router.push(‘/’); } }); function setMenu(routes) { const menu = []; for (const route of routes) { if (route.children) { for (const child of route.children) { if (child.meta && child.meta.title) { const menuItem = { index: child.path, path: route.path + ‘/’ + child.path, label: child.meta.title, aaaaa: child.meta.aaaaa, }; menu.push(menuItem); } } } } menuList.value = menu } function logOut() { userStore.logOut(); ElMessage.success(‘已退出登录’); router.push(‘/’); } </script> <style scoped> .layout-container-demo .el-header { position: relative; background-color: var(--el-color-primary-light-7); color: var(--el-text-color-primary); } .layout-container-demo .el-aside { color: var(--el-text-color-primary); background: var(--el-color-primary-light-8); height: 100vh; } .layout-container-demo .el-menu { border-right: none; } .layout-container-demo .el-main { padding: 0; } .layout-container-demo .toolbar { display: inline-flex; align-items: center; justify-content: center; height: 100%; right: 20px; } </style> 我想把 用户管理画面,项目一览画面,项目管理画面 ,障碍票一览画面,障碍票详细画面 加入上部导航栏中,然后在丰富一下画面内容 用<template>画
07-23
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

我先来一碗

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值