element中的Popover 弹出框

element中的Popover 弹出框

实现功能:

1、当鼠标悬浮于“网站”按钮时弹出网站名称、是否收藏。
2、点击相关的网站名称在浏览器新页面打开该名称的网站。
3、点击“收藏”按钮,把用户名和相应的网站名称记入浏览器localStorage中。
图片展示

实现代码:

<template>
  <div>
    <el-popover
				placement="right"
				width="400"
				trigger="hover" >
				<el-table :data="gridData" >
          <!-- 使用vue的solt插槽结合element中的scope.row实现获取相应的链接 -->
					<el-table-column width="280" prop="address" label="网站名称" property="Newname" >
						<template slot-scope="scope">
							<a :href="scope.row.address" target="_blank" >{{scope.row.Newname}}</a>
						</template>
					</el-table-column>
					<!-- 同上,外加使用getValue()函数,把scope.row.Newname作为参数传入函数,使得可以在script模块中获取新闻标题 -->
					<el-table-column width="80" label="是否收藏" prop="Newname" >
						<template slot-scope="scope">
							<el-button  @click="getValue(scope.row.Newname)">{{ scope.row.date }}</el-button>
						</template>
						
					</el-table-column>
				</el-table>
				<el-button slot="reference" class="h">网站</el-button>
					
			</el-popover>
  </div>
</template>

<script>
export default {
	data() {
      return {
		bb:"",
		valueArr:[],
        gridData: [
			{
				date:"收藏",
				Newname:"百度",
				address: 'http://www.baidu.com/'
			},
			{
				date: '收藏',
				Newname:"京东",
				address: 'https://www.jd.com/'
			},
			{
				date: '收藏',
				Newname:"淘宝",
				address:"https://www.taobao.com/"
			},
			{
				date: '收藏',
				Newname:"b站",
				address:"https://www.bilibili.com/"
			},
	]
      };
    },
	
	methods: {
		getValue(value){
			this.valueArr.push(value);
			localStorage.setItem('zhangsan',this.valueArr);
		},
		
	},
	
}
</script>

<style>
a{
  text-decoration: none;
}
</style>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值