antd mobile(八) webpack通过别名取代路径引用
来源:互联网 发布:python 字典转成list 编辑:程序博客网 时间:2024/06/06 09:59
开发了好几个界面了,发现路径引用非常麻烦,而且非常的长。比如下面的代码:
//自己封装的js组件import { GoingNav,GoingScroll } from './../../../components/goingMobile';//自己封装的工具类jsimport {DateFun} from '../../../utils/goingUtils';
有一次温习webpack的时候,发现还可以通过webpack取别名代替路径引用,价值就不用赘述了,果断的对项目做了一次简单的重构。
找到root下的webpack.config.js文件,将配置加入其中:
webpackConfig.resolve={ //自动扩展文件后缀名,意味着我们require模块可以省略不写后缀名 alias: { 'GoingMobile': path.resolve(__dirname, 'src/components/goingMobile'), 'GoingUtils': path.resolve(__dirname, 'src/utils/goingUtils') } };
修改界面引入的代码:
import { GoingNav,GoingScroll } from 'GoingMobile';import {DateFun} from 'GoingUtils';
启动项目,一切都ok。
阅读全文
0 0
- antd mobile(八) webpack通过别名取代路径引用
- antd-mobile
- Webpack中使用相对路径定义别名
- antd mobile(一) 环境搭建
- antd mobile(七) 固定NavBar
- webpack+react+antd 单页面应用实例
- webpack react antd遇到的问题
- react引用antd-form组件
- antd-mobile中listView遇到的坑
- antd-mobile 手机显示字体太大
- antd mobile (三) 集成highcharts--传统方式
- 使用antd-mobile遇到的坑
- antd mobile(十二) dva中使用mockJs
- react项目的组件库antd-mobile
- create-react-app + antd-mobile配置
- webpack引用动态资源路径错误的解决方案
- webpack中alias别名配置
- antd
- ALLEGRO学习之如何出GERBER
- 适配器模式-对象,类,接口三种适配器
- 分布式,java,高并发系统设计,大神学习路线
- 51nod 1007 正整数分组(类背包)
- swift3.0 如何优雅的自定义tableViewcell,最简单的自定义cell,闭包事件传递,代码封装。
- antd mobile(八) webpack通过别名取代路径引用
- 文件管理
- 论文见解之SRN: Side-output Residual Network for Object Symmetry Detection in the Wild
- js判断浏览器类型
- 高性能网站架构设计之缓存篇(7)- Redis哨兵sentinel机制用法与说明
- HTML学习经验总结
- 微信统一下单_公众号支付_扫码支付
- C#解析XML字符串
- iOS UIWebView 注入Cookie