vue-cli 中集成sass报错

发布于 2022-09-07 04:11:02 字数 3445 浏览 6 评论 0

使用vue-cli搭建的
npm install node-sass sass-loader --save-dev
正常安装了

代码如下
<template>
<div class="tabMain">

<table>
  <thead>
    <tr>
        <th>1</th>
        <th>1</th>
        <th>1</th>
        <th>1</th>
    </tr>
  </thead>
  <tbody>
    <tr>
        <td>1</td>
        <td>1</td>
        <td>1</td>
        <td>1</td>
    </tr>
    <tr>
        <td>1</td>
        <td>1</td>
        <td>1</td>
        <td>1</td>
    </tr>
    <tr>
        <td>1</td>
        <td>1</td>
        <td>1</td>
        <td>1</td>
    </tr>
    <tr>
        <td>1</td>
        <td>1</td>
        <td>1</td>
        <td>1</td>
    </tr>
  </tbody>
</table>

</div>
</template>

<script>
export default {
name: 'HelloWorld',
data () {

return {
  // msg: 'Welcome to Your Vue.js App'
}

}
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<!--style scoped>
.tab{

text-align: center;
margin: 0 auto;

}
</style-->
<style lang="sass" scoped>
.tabMain{

}

</style>

sass报错如下

Module build failed:
undefined
        ^
      Invalid CSS after ".tabMain{": expected "}", was "{}"
      in D:\wYcom\braTab\src\components\braTab.vue (line 61, column 10)

 @ ./node_modules/vue-style-loader!./node_modules/css-loader?{"sourceMap":true}!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-346945b4","scoped":true,"hasInlineConfig":false}!./node_modules/sass-loader/lib/loader.js?{"indentedSyntax":true,"sourceMap":true}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./src/components/braTab.vue 4:14-397 13:3-17:5 14:22-405
 @ ./src/components/braTab.vue
 @ ./src/router/index.js
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js



 WAIT  Compiling...                                                                                                                   14:22:48

 94% asset optimization

 ERROR  Failed to compile with 1 errors                                                                                               14:22:48

 error  in ./src/components/braTab.vue

Module build failed:
undefined
        ^
      Invalid CSS after ".tabMain{": expected "}", was "{}"
      in D:\wYcom\braTab\src\components\braTab.vue (line 61, column 10)

 @ ./node_modules/vue-style-loader!./node_modules/css-loader?{"sourceMap":true}!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-346945b4","scoped":true,"hasInlineConfig":false}!./node_modules/sass-loader/lib/loader.js?{"indentedSyntax":true,"sourceMap":true}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./src/components/braTab.vue 4:14-397 13:3-17:5 14:22-405
 @ ./src/components/braTab.vue
 @ ./src/router/index.js
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半窗疏影 2022-09-14 04:11:02

这个百度上面有教如何webpack配置sass的
webpack.config.js要配置scss-loader
还有
<style lang=“scss”>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文