SCSS与Vue3应用程序不兼容(TypeError:this.getOptions不是函数)

3

我正在尝试在vue3应用中使用scss,但是遇到以下错误:

./src/components/SinglePost.vue?vue&type=style&index=0&id=164ef990&lang=scss (./node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!./node_modules/vue-loader-v16/dist/stylePostLoader.js!./node_modules/postcss-loader/src??ref--8-oneOf-1-2!./node_modules/sass-loader/dist/cjs.js??ref--8-oneOf-1-3!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader-v16/dist??ref--0-1!./src/components/SinglePost.vue?vue&type=style&index=0&id=164ef990&lang=scss) Module build failed (from ./node_modules/sass-loader/dist/cjs.js): TypeError: this.getOptions is not a function at Object.loader (/usr/src/app/node_modules/sass-loader/dist/index.js:25:24)

我已经按照https://vue-loader.vuejs.org/guide/pre-processors.html页面上的说明进行了设置。我正在使用vue-cli-service serve命令启动服务器。下面是singlepost.vue中的代码。如果使用此命令启动服务是否需要创建webpack.config.js文件,我不确定。

<style lang="scss">
.btn {
    &,
    &:link,
    &:visited {
    text-transform: uppercase;
    text-decoration: none;
    padding: 1.5rem 4rem;
    display: inline-block;
    border-radius: 10rem;
    transition: all .3s;
    position: relative;
    //  
    }
.....etc etc 
</style>

请指导我,我是新手网站开发。


嘿,可能有点晚了,但我已经使用命令将我的sass-loader降级到10.1.1:npm install sass-loader@^10.1.1 - Valdemar Vreeman
2个回答

7

或者运行

npm install -D sass-loader@10.1.1 sass

0

这两个软件包解决了这个问题,

"node-sass": "^4.0.0",
"sass-loader": "^7.0.0"

请参见 https://github.com/webpack-contrib/sass-loader/issues/923。 - theking2

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接