當(dāng)遇到需要在點(diǎn)擊事件或函數(shù)中實(shí)現(xiàn)打開(kāi)新頁(yè)面攒读,新窗口打開(kāi)需求時(shí)
在點(diǎn)擊事件中寫(xiě):
<el-button type="primary" icon="el-icon-printer" plain @click="handlePrint">打印報(bào)表</el-button>
// 打印報(bào)表
handlePrint() {
const ids = '12'
const routeData = this.$router.resolve({
path: '/print',
query: { ids: ids, pageFrom: 'back' }
})
window.open(routeData.href, '_blank')
}
瀏覽器地址欄顯示所攜帶參數(shù)
注:前提是已經(jīng)設(shè)置好路由頁(yè)面設(shè)置,如router/index.js
export const constantRoutes = [
{
path: '/print',
component: () => import('@/views/print/index'),
hidden: true,
name: 'print'
}
]