vue-cli 遇到的问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_34255080/article/details/77877985

1:切换子路由时,数据不刷新,在子路由进入时,观察watch

代码:

watch:{
'$route'(to,from){
const toDepth = to.path.split('/').length
const fromDepth = from.path.split('/').length
console.log(toDepth,fromDepth)
this.centerIndex = toDepth < fromDepth ? 'centerIndexx' : 'centerIndexx1'
}
},


2:axios post 传递表单时候 header

在main.js加入

axios. defaults. headers. post[ 'Content-Type'] = 'application/x-www-form-urlencoded';
json.stringify()为了防止数据传输为object,object

3:弹出层之后防止body滚动

在写移动端页面的时候,弹出遮罩层后,我们仍然可以滚动页面。 
vue中提供 @touchmove.prevent 方法可以完美解决这个问题

<div class="dialog" @touchmove.prevent ></div


猜你喜欢

转载自blog.csdn.net/qq_34255080/article/details/77877985