更新时间:2023-02-01 18:21:51
我使用生命周期挂钩 beforeCreate
和全局样式表.在 global.css
中:
I got it working with the lifecycle hook beforeCreate
and a global stylesheet. In global.css
:
body.home {
background: red;
}
body.intro {
background: pink;
}
在 HomeView.vue
的< script>
部分中:
export default {
beforeCreate: function() {
document.body.className = 'home';
}
}
和 IntroView.vue
中的类似.