mounted() {
        document.querySelector('body').setAttribute('style', 'background-color:#f6f6f6')
    },
    beforeDestroy() {
        document.querySelector('body').removeAttribute('style')
    },

 使用上面的方式就可以为当前页面设置背景色了,mounted()在模板渲染成html后调用,beforeDestroy()销毁实例前调用

Logo

基于 Vue 的企业级 UI 组件库和中后台系统解决方案,为数万开发者服务。

更多推荐