我使用Laravel 5.4 Vue.js 2. 在VUE组分,我想使用文档\ressources\assets\sass\_variables.scss
中指定的变量。Vue.js:如何使用变量从laravel preifined _variables.scss文件?
这是我的代码:
<template>
...
<template>
<style lang="sass">
#note
color: $brand-info
</style>
这个变量文件的文件\ressources\assets\sass\app.scss
在编译进口,NPM返回以下错误:
> Module build failed:
> color: $brand-info
> ^
> Undefined variable: "$brand-info".
> in C:\www\projects\crm\resources\assets\js\components\person-show.vue
> (line 150, column 12)
如果我通过更换$brand-info
它编译没有错误。
怎么可能使用这个变量? 任何提示将非常感激。
您需要导入'app.scss'文件到您的组件的样式部分。 – thanksd
@thanksd app.scss(app.css)的编译版本已经导入到组件的使用位置。 – Warrio
组件的样式部分的作用域没有考虑到它父级的作用域。据我所知,您需要在组件的作用域中定义sass变量或从指定的文件中导入它们。 – thanksd