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

2017-08-03  本文已影响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: [] #加这一句
 },

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

上一篇 下一篇

猜你喜欢

热点阅读