I am using a Vue router with two pages:
let routes = [ { path: '/', component: require('./components/HomeView.vue') }, { path: '/intro', component: require('./components/IntroView.vue') } ]
This works great, except that each of my components has different body styles:
HomeView.vue:
<template> <p>This is the home page!</p> </template> <script> export default { } </script> <style> body { background: red; } </style>
IntroView.vue:
<template> <div> <h1>Introduction</h1> </div> </template> <script> export default { } </script> <style> body { background: pink; } </style>
My goal is for these two pages to have different background styles (eventually with a transition between them). But at the moment when I go to the home route (with a red background), then click on the intro route, the background color remains red (I want it to change to pink ).
Edit: index.html:
<body> <div id="app"> <router-link to="/" exact>Home</router-link> <router-link to="/intro">Introduction</router-link> <router-view></router-view> </div> <script src="/dist/build.js"></script> </body>
source share