美文网首页
记一个学习Vue时import css 的问题

记一个学习Vue时import css 的问题

作者: 东京的雨不会淋湿首尔 | 来源:发表于2017-08-03 15:55 被阅读381次

vue 2.0

我觉得是个坑。。。

以swiper为例,先看下报错情况

#引入
import Swiper from "swiper"
import 'swiper/dist/css/swiper.css'
#配置
{
        test: /\.css/,
        loader: "style-loader!css-loader",
 },
 ERROR  Failed to compile with 1 errors15:48:43

This dependency was not found:

* swiper/dist/css/swiper.css in ./~/babel-loader/lib!./~/vue-loader/lib/selector.js?type=script&index=0!./src/components/slider.vue

To install it, you can run: npm install --save swiper/dist/css/swiper.css

虽然不知道为什么,但是如果在配置文件里加

{
        test: /\.css/,
        loader: "style-loader!css-loader",
        include: [] #加这一句
 },

然后一切都正常了,阳光明媚,春暖花开

相关文章

网友评论

      本文标题:记一个学习Vue时import css 的问题

      本文链接:https://www.haomeiwen.com/subject/riyplxtx.html