1

I'm working on a Vue.js + webpack project. I've tried several ways but my css won't work. This is my code

<style scoped> 
@import './styles/home.css';
</style>
<template>
<div class="hello">
  <div class="menu" >{{who}}
    <button @click="info()">Inforation</button>
  </div>
  <router-view/>
</div>
</template>

home.css

.menu{
width: 100%; 
height:60px;  
background-color:#E0E0E0; 
font-family:Helvetica; 
left:100px; 
top: 150px;
}
button {
background-color: #4CAF50; 
color: white; 
padding: 14px 20px; 
margin: 8px 0; 
border: none; 
cursor: pointer;
width: 100px; 
float:right;
} 

compiling using npm run build, and run by app.js I have tried using .hello >>> .menu but don't work.

webpack-config

module: {
  rules: [
    {
    test: /\.css$/,
    use: [
      'vue-style-loader',
      'css-loader',
    ]
    },
   ]
 }
jamiecheng
  • 23
  • 4

1 Answers1

0

You are using <style scoped>. This would only work for local css, not for imported styles. Try using <style> with an external CSS file.

Ferry Kranenburg
  • 2,073
  • 1
  • 15
  • 21