js添加类名移除类名
添加类名
classList.add
document.getElementById('app').classList.add("appForSearch")
移除类名
classList.remove
document.getElementById('app').classList.remove("appForSearch")
监听路由变化动态添加
watch:{ $route(){ if(this.$route.path == '/Search'){ document.getElementById('app').classList.add("appForSearch") }else{ document.getElementById('app').classList.remove("appForSearch") } } }