6
一天一个 Element 组件 - 简单介绍入口文件
source link: https://shiningdan.github.io/2020/01/01/%E4%B8%80%E5%A4%A9%E4%B8%80%E4%B8%AA-Element-%E7%BB%84%E4%BB%B6-%E9%A1%B9%E7%9B%AE%E7%BB%93%E6%9E%84%E4%B8%8E%E5%85%A5%E5%8F%A3%E6%96%87%E4%BB%B6/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
一天一个 Element 组件 - 简单介绍入口文件
本文是 Element 的组件源码学习系列。
项目源码:ElemeFE/element | GitHub,Tag:v2.13.0
一般我们在看一个项目,首先要看的是这个项目的目录结构和 package.json
。
项目结构中:
.github
存放的是如何提 PR、Issus、贡献代码的流程build
里面放的是打包构建的脚本examples
里面放的是组件示例packages
里面是组件源码src
放的是入口文件,还有一些其他辅助文件test
里面是单测文件types
是类型定义文件components.json
配置文件里面列出了组件目录,以及对应源码的位置,应该是给 webpack 打包的时候使用的
来看一下入口文件 src/index.js
吧。
import Pagination from '../packages/pagination/index.js'; |
前面定义的是 Element 的 install 方法。因为 Element 是基于 Vue 的组件库,所以在调用 install 方法的时候,要判断 Vue 对象已经被挂载到了 window
上:
/* istanbul ignore if */ |
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK