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") } } }
标签:classList,app,js,getElementById,appForSearch,移除,document,类名 来源: https://www.cnblogs.com/myqinyh/p/16168439.html