一、点击事件换成a标签跳转

<template #op="{ row }">  
	<a href="javascript:void(0)" onclick="window.open()"></a>
</template>

二、携带参数方法

因为要携带参数row,不能直接使用window.open(),可以将onclick点击事件的方法挂载在window上。

<template #op="{ row }">  
	<a href="javascript:void(0)" :row=JSON.stringify(row) onclick="javascript:goPay(this)"></a>
</template>
  1. vue项目里method的goPay是定义不了的,所以需要在created生命周期里挂载在window上。
  2. 要传递row参数只能另辟蹊径写到a标签元素的属性上。通过this获取到,this指当前元素。用getAttribute方法获取元素的属性值。
created() {
	window.goPay = this.goPay
},
methods: {
	goPay() {
		const data = Object.assign({nsrsbh:this.nsrData.nsrsbh},JSON.parse(row.getAttribute('row')))
		const newPage = this.$router.resolve({name:'ylPay'})
		window.open(newPage.href)
	}
}

注意,window.open只能放在同步方法里,不能放在异步方法里,异步调用需要转至新页面。

Logo

前往低代码交流专区

更多推荐