0%

Vue踩坑

  1. 如果要启用css module 需要在style标签中插入 module 属性,否则不会生效

  2. 独立样式表文件的话需要在 style 标签中 @import ‘./App.scss’ 这样引入,仍然使用 :class=”$style.red” 这样的形式使用

  3. autodll-webpack-plugin 插件 path 和webpack的 publicPath冲突

  4. mini-css-extract-plugin 配置完loader之后还需要配置plugins,2019年11月12号因为忘记配置plugins,导致一致报错,看了半小时。

  5. Vue-router 如果使用 history 模式,会有刷新页面就会404的问题,原因是SPA中当你刷新页面的时候实际请求的是该路径下的页面,但SPA只有index.html因此导致404,开发环境如果用webpack-dev-server,设置historyApiFallback属性为true,生产环境nginx配置try_files $uri $uri/ /index.html;

  6. 组件赖加载,babel 7.x 以后需要使用插件 @babel/plugin-syntax-dynamic-import

  7. 如果在.babelrc 中配置了corejs,版本3,需要安装 core-js 和 regenerator-runtime,可在入口js文件中导入:

    1
    2
    import 'core-js/stable'
    import 'regenerator-runtime/runtime'