vue项目出现问题
1.vue+elementUi项目中 饿了么组件上不能直接添加事件,要加上.native
<el-card :body-style="{ padding: '0px' }" class="singleItem" :style="{width:newItem.itemWidth+'px'}" @click.native="navVideoPlay(newItem)">
或者是在组件上面加个div,在div上添加事件。
2.阻止事件冒泡事件
整个图片有个点击事件,官方这里也有个点击事件,阻止事件冒泡:可以在官方的点击事件上加上 .stop
<span class="left" style="cursor: pointer;" @click.stop="anchorDetail">{{ item.author }}</span>
3.更改页面title
main.js中添加如下代码
router.beforeEach((to, from, next) => {
/* 路由发生变化修改页面title */
//to.params.type中type是要传的值的名称
if (to.params.type) {
// document.title是默认的文档标题
document.title = to.params.type || '首页'
}
next()
})