在我之前的 Angular 应用程序中,我能够在另一个窗口中打开我的简历,如下所示:
<a class="link popup" href="javascript:void(0);" onclick="javascipt:window.open('./../../assets/Resume_Christopher_Kade.pdf');">Resume</a>
在用 Vue 重写我的网站时,我注意到它没有按预期工作,将其更改为:
<a class="link popup" href="javascript:void(0);" v-on:click="openPdf()">Resume</a>
With openPdf()
在我的组件的方法中:
openPdf () {
javascipt:window.open('./../assets/Resume_Christopher_Kade.pdf');
}
单击该链接时,将打开一个新页面,网址为:
http://localhost:8080/assets/Resume_Christopher_Kade.pdf
同时在屏幕上显示空路线,而不是在浏览器的 pdf 查看器中显示 pdf。
这个问题可能与我在 Vue 中处理路由的方式有关:
export default new Router({
mode: 'history',
routes: [
{
path: '/',
name: 'Home',
component: Home
},
{
path: '/work',
name: 'Work',
component: Work
},
{
path: '/posts',
name: 'Posts',
component: Posts
},
{ path: '*', component: Home }
]
})
为什么它不像 Angular 那样简单?我错过了什么吗?