1

I added this css rule

<style>
body {
  background-color: rgb(184, 182, 182);
}

#app {
...
</style>

to my App.vue file within the tag (not scoped ;-); as learned in vue mastery courses. Which BTW are a great help!

This approach also is proposed by Babacadabra in a related post.

Everything builds fine, and the locally defined (scoped) styles of a component can be found in the dist/css folder. But my global style declaration for the background-color disappeared. As result the website layout is different than the one I tested locally (using 'vue serve'):

The background color is not applied.

What am I making wrong?

I helped myself by adding the background-color declaration directly to my index file, but that should be a patch only. I'm looking for a final solution, so the complete workflow works as expected and local and remote versions behave the same.

UPDATE (more code): As requested here more details, i.e. the complete App.vue. I hope that is sufficient, since to my (very basic ;.-) understanding of vue the global style declarations go into this Module.

<template>
  <div id="app">
    <img class="vservuLogo" alt="VservuLogo" src="./assets/VservU-Logo.png">
    <HelloWorld msg="Welcome to VservU GmbH Munich"/>
  </div>
</template>

<script>
import HelloWorld from "./components/HelloWorld.vue";

export default {
  name: "app",
  components: {
    HelloWorld
  }
};
</script>

<style>
body {
  background-color: rgb(184, 182, 182);
}

#app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
.vservuLogo {
  width: 50%;
}
</style>

UPDATE2:

Since I could not reproduce that behavior in a new project, I guess I simply missed to clear the cache!

hnuecke
  • 137
  • 1
  • 9
  • please add more code snippet to be more clear – Boussadjra Brahim Sep 04 '18 at 16:00
  • What else do you need? I don't think the complete App.vue does unveil more needed details, but here you go: – hnuecke Sep 04 '18 at 21:19
  • Oops, I was to slow and could no more edit my comment, that's the reason of this next comment; sorry! I added the complete App.vue to my original question. The comment does not offer enough space ;-) – hnuecke Sep 04 '18 at 21:26
  • i will try it out – Boussadjra Brahim Sep 04 '18 at 21:31
  • it works fine on my code and the given background-color is applied – Boussadjra Brahim Sep 04 '18 at 21:36
  • strange... Do you have any idea what could go wrong on my side? You can check it out; the website is available onsite : https://vservu.megazine3.de – hnuecke Sep 04 '18 at 22:55
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/179420/discussion-between-boussadjra-and-hnuecke). – Boussadjra Brahim Sep 04 '18 at 23:39
  • OK... Just to share my actual findings: I setup a completely new project and only added the background-color to body... And it worked! I also found that style declaration in the obviously combined css file. My obviously incorrect assumption was, that this css file only contained the scoped declarations; what was wrong: It contains everything! The selectors of the scoped ones contain specific attribute selectors like: [data-v-216abc19] Lessons learned ;-) I do not know what went wrong, Actually, it looks like everything is working as expected. Sorry for keeping you busy! – hnuecke Sep 05 '18 at 08:22
  • no problem, you are welcome – Boussadjra Brahim Sep 05 '18 at 12:01

0 Answers0