私はVueJS
とWebpack
の世界ではかなり新しいので、何か助けが必要です。独自の変数を持つすべてのVueコンポーネントでCSSフレームワークを使用
私は
vue init webpack my-project
コマンドでコンソールを介したVueJS
とWebpack
をインストールしたし、この後、私はこのディレクトリにbulma CSS Frameworkをインストールしました。
npm install bulma
と私はvariables.scssにいくつかのbulma
の変数を上書きしてきました。両方のファイルを私のApp.vueのスタイルセクションにインポートすると問題なく動作します。
マイApp.vueは次のようになります。
<template>
<div id="app">
<top-navigation/>
<div class="has-text-centered">
<img src="./assets/logo.png">
<p>Test</p>
<router-view></router-view>
</div>
</div>
</template>
<script>
import TopNavigation from './components/shared/TopNavigation.vue'
export default {
name: 'app',
components: {
'top-navigation': TopNavigation
}
}
</script>
<style lang="scss">
@import 'assets/scss/_variables.scss';
@import '~bulma';
</style>
マイTopNavigation.vueは次のようになります。
<template>
<div>
<div class="blue-bg">
<div class="container">
<h2 class="title">Test</h2>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
msg: 'hello vue'
}
}
}
</script>
<style lang="scss">
.blue-bg {
height: 80px;
background-color: $blue;
}
</style>
しかし、私はエラーを取得する:
error in ./src/components/shared/TopNavigation.vue
Module build failed: background-color: $blue;
Undefined variable: "$blue".
私はしばらくの間を検索し、このように私のwebpack
utils.jsファイルに直接ファイルをインポートしようとしました:今、私はエラーを取得しないと私のTopNavigation
に使用している
scss: generateLoaders(['css', '[email protected] "./src/assets/scss/_variables.scss";@import "~bulma";']),
右の青色。しかし今やbulma-variable
は無効になりません。
私は皆さんが私の問題を理解し、誰かが私にこれを手伝ってくれることを願っています。