第一步:开发配置(使用node.js,express框架)
    1.新建目录antdComponent
    2.进入跟文件夹antdComponent
    3.初始化文件,执行npm init创建package.json文件
    4.安装依赖 npm install add express, npm install add superagent, npm install add cheerio
    注:express (使用express来搭建一个简单的Http服务器。当然,你也可以使用node中自带的http模块)
    superagent (superagent是node里一个非常方便的、轻量的、渐进式的第三方客户端请求代理模块,用他 来请求目标页面)
    cheerio (cheerio相当于node版的jQuery,用过jQuery的同学会非常容易上手。它主要是用来获取抓取到 的页面元素和其中的数据信息)

    作者:MagicEyes
    链接:https://juejin.im/post/5b4f007fe51d4519277b9707
    来源:掘金
    著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
    第二部:开始coding
    1.在根目录下创建index.js文件
    2.创建好index.js后,我们首先实例化一个express对象,用它来启动一个本地监听3000端口的Http服务。

    1. const express = require('express');
    2. const app = express();
    3. // ...
    4. let server = app.listen(3000, function () {
    5. let host = server.address().address;
    6. let port = server.address().port;
    7. console.log('Your App is running at http://%s:%s', host, port);
    8. });

    3.按照国际惯例,我们希望在访问本机地址http://localhost:3000的时候,这个服务能给我们犯规一个Hello World!index.js中加入如下代码:

    1. app.get('/', function (req, res) {
    2. res.send('Hello World!');
    3. });

    此时,在DOS中项目根目录baiduNews下执行node index.js,让项目跑起来。之后,打开浏览器,访问http://localhost:3000,你就会发现页面上显示’Hellow World!’字样。
    这样,在后面我们获取到信息后,就可以在访问http://localhost:3000时看到这些信息。

    4.分析页面结构

    image.png
    找到所需要的信息所在节点
    5.开始进行爬取,我这里封装了两个函数,分别爬取了如4图中的左边组件列表包含了每个组件的链接地址(每一个组件都有一个地址)及基本信息和右边的api信息,函数如下
    1.分析结构,找到你想要的
    2.函数封装(一个函数只做一件事)
    1.获取组件列表

    1. /**
    2. *
    3. * @param {String} docUrl
    4. * @return {Array} [{title, name, category, url}]
    5. */
    6. async function getComponentList(url){
    7. let componentList = []
    8. let list=await new Promise(resolve=>{
    9. superagent.get(url).end((err, res) => {
    10. if (err) {
    11. // 如果访问失败或者出错,会这行这里
    12. console.log(`组件链接列表请求 - ${err}`)
    13. } else {
    14. let $ = cheerio.load(res.text);
    15. $('.ant-menu .ant-menu-item-group .ant-menu-item').each((idx, ele) => {
    16. let component = {
    17. name:$(ele).find('span').eq(0).text(),
    18. title:$(ele).find('span').eq(1).text(),
    19. category:$(ele).parent('.ant-menu-item-group-list').prev('div').text(),
    20. url: 'https://ant.design'+$(ele).find('a').attr('href')
    21. }
    22. componentList.push(component)
    23. });
    24. resolve(componentList)
    25. }
    26. });
    27. });
    28. return list;
    29. };

    2.获取单个组件apis

    1. /**
    2. * 获取组件的API
    3. * @param {String} url
    4. * @return {Array} [{name, type, description, defaultValue}]
    5. */
    6. async function getComponentApis(url){
    7. let getComponentApis=[]
    8. //let arry = []
    9. let apis = await new Promise(resolve=>{
    10. superagent.get(url).end((err, res) => {
    11. if (err) {
    12. // 如果访问失败或者出错,会这行这里
    13. console.log(`组件apis请求失败 - ${err}`)
    14. } else {
    15. let $ = cheerio.load(res.text);
    16. $('#react-content .api-container table').each((idx, ele) => {
    17. // cherrio中$('selector').each()用来遍历所有匹配到的DOM元素
    18. // 参数idx是当前遍历的元素的索引,ele就是当前便利的DOM元素
    19. if(idx === 0){
    20. getComponentApis = parseApis(ele)
    21. }
    22. });
    23. resolve(getComponentApis)
    24. }
    25. });
    26. })
    27. return apis
    28. }

    3.获取单个组件的自组件

    1. /**
    2. * 获取组件的子组件
    3. * @param {String} url
    4. * @return {Array} [{ title, name, category, url, apis }]
    5. */
    6. async function getSubComponent(url, category){
    7. var allDOM
    8. let componentNames = await new Promise(resolve=>{
    9. superagent.get(url).end((err, res) => {
    10. if (err) {
    11. // 如果访问失败或者出错,会这行这里
    12. console.log(`组件apis请求失败 - ${err}`)
    13. } else {
    14. allDOM = res.text
    15. let $ = cheerio.load(res.text);
    16. let subNameList = []
    17. $('#react-content .api-container h3 span').each((idx, ele) => {
    18. // cherrio中$('selector').each()用来遍历所有匹配到的DOM元素
    19. // 参数idx是当前遍历的元素的索引,ele就是当前便利的DOM元素
    20. subNameList.push($(ele).text())
    21. });
    22. resolve(subNameList)
    23. }
    24. });
    25. })
    26. let subComponents = componentNames
    27. .slice(1)
    28. .map(name => {
    29. return {
    30. name,
    31. title: '',
    32. category,
    33. url,
    34. apis: []
    35. }
    36. }).map(comp => {
    37. let apis = []
    38. let $ = cheerio.load(allDOM);
    39. $('#react-content .api-container table').each((idx, ele) => {
    40. // cherrio中$('selector').each()用来遍历所有匹配到的DOM元素
    41. // 参数idx是当前遍历的元素的索引,ele就是当前便利的DOM元素
    42. if(idx !== 0){
    43. apis = parseApis(ele)
    44. }
    45. });
    46. return {
    47. ...comp,
    48. apis
    49. }
    50. })
    51. return subComponents
    52. }

    3.调用函数,得到想要的结构

    1. app.get('/parse', async (req, res, next) => {
    2. const docLink = 'https://ant.design/components/button-cn/'
    3. let componentList = await getComponentList(docLink)
    4. //let nameList = []
    5. for (let component of componentList) {
    6. try {
    7. // 1 get api
    8. let componentApis = await getComponentApis(component.url)
    9. //2 get subComponents
    10. let subComponents = await getSubComponent(component.url,component.category)
    11. // 3 查询api中文名 label
    12. let der = {
    13. disabled: "是否禁用",ghost: "按钮背景透明",href: " 点击跳转的地址",htmlType: " 设置button的原生type值",
    14. icon: "图标类型",loading: "载入状态",shape: "形状",size: "大小",target: "相当于a链接的target属性",
    15. type: "类型",onClick: "点击按钮时的回调",block: "将按钮的宽度调整为其父宽度的选项",style: "图标的样式",
    16. theme: "图标的主题风格",spin: "是否有旋转动画",rotate: "图标旋转角度",component: "组件",twoToneColor: "双色图标颜色",
    17. scriptUrl: "项目生成的js地址",extraCommonProps: "svg图标设置额外的属性",width: "元素宽度",height: "元素高度",
    18. fill: "元素的填充颜色",className: "类名",copyable: "是否可拷贝", delete: "删除",editable: "是否可编辑",
    19. ellipsis: "省略号",mark: "标记",underline: "下划线",strong: "加粗",level: "重要程度",onChange: "提交编辑内容时触发",
    20. align: "对齐方式",gutter: "栅格间隔",justify: "水平排列方式",offset: "栅格左侧间隔",order: "栅格顺序",
    21. pull: "栅格向左移动格数",push: "栅格向右移动格数",span: " 栅格占位格数",xs: " <576px 响应式栅格",sm: " ≥576px 响应式栅格",
    22. md: " ≥768px 响应式栅格",lg: " ≥992px 响应式栅格",xl: " ≥1200px 响应式栅格",xxl: "≥1600px 响应式栅格",
    23. hasSider: "有sider",breakpoint: "断点",collapsed: "收起状态",collapsedWidth: "收缩宽度",collapsible: "是否可收起",
    24. defaultCollapsed: "是否默认收起",reverseArrow: "翻转折叠",trigger: "自定义tigger",onCollapse: "收起时的回调函数",
    25. onBreakpoint: "断点时的回调",zeroWidthTriggerStyle: "0宽度触发样式",offsetBottom: "偏移底部",offsetTop: "偏移顶部",
    26. itemRender: "项目渲染",params: "参数",routes: "路由栈信息",separator: "分隔符",overlay: "下拉菜单内容",
    27. children: "要显示的分隔符",getPopupContainer: "菜单渲染父节点",overlayClassName: "下拉根元素的类名称",
    28. overlayStyle: "下拉根元素的样式",placement: "菜单弹出位置",visible: "是否显示",onVisibleChange: "显示状态改变时调用",
    29. defaultOpenKeys: "初始展开的菜单项key数组",defaultSelectedKeys: "初始选中的菜单项key数组",
    30. forceSubMenuRender: "在子菜单展示前就渲染DOM",inlineCollapsed: "内联模式折叠",inlineIndent: "内联模式缩进",
    31. mode: "菜单类型", multiple: "是否允许多选",openKeys: "菜单项key数组",selectable: "可选",selectedKeys: "选定的键",
    32. subMenuCloseDelay: "子菜单关闭延迟",subMenuOpenDelay: "子菜单开启延迟",onDeselect: "取消选择",onOpenChange: "展开/关闭的回调",
    33. onSelect: "选择",overflowedIndicator: "指标溢出",key: "键",title: "标题", popupClassName: "弹出类别名称",
    34. onTitleClick: "在标题上单击",current: "当前页数",defaultCurrent: "默认当前页数",defaultPageSize: "默认页面大小",
    35. hideOnSinglePage: "默认每页条数",pageSize: "每页条数",pageSizeOptions: "指定每页显示条数",showLessItems: "显示较少的项目",
    36. showQuickJumper: "快速跳转至某页",
    37. showSizeChanger: "改变pageSize",
    38. showTotal: "显示总和",
    39. simple: "简单分页",
    40. total: "总页数",
    41. onShowSizeChange: "pageSize变化的回调",
    42. subTitle: "副标题",
    43. avatar: "头像",
    44. backIcon: "后退图标",
    45. tags: "标签",
    46. extra: "额外信息",
    47. breadcrumb: "面包屑",
    48. footer: "页脚",
    49. onBack: "返回按钮的点击事件",
    50. direction: "步骤条方向",
    51. labelPlacement: "标签放置位置",
    52. progressDot: "点状步骤条",
    53. status: "当前步骤的状态",
    54. initial: "起始序号",
    55. description: "详情描述",
    56. allowClear: "允许清除",
    57. autoFocus: "自动对焦",
    58. backfill: "回填",
    59. children:"子项",
    60. dataSource: "数据源",
    61. dropdownMenuStyle: "菜单自定义样式",
    62. defaultActiveFirstOption: "默认高亮第一个选项",
    63. defaultValue: "默认值",
    64. filterOption: "过滤器选项",
    65. optionLabelProp: "回填选择框的option属性值",
    66. placeholder: "输入框提示",
    67. value: "指定值",
    68. onBlur: "模糊",
    69. onFocus: "获取焦点",
    70. onSearch: "搜索补全项",
    71. defaultOpen: "默认打开",
    72. open: "打开",
    73. onDropdownVisibleChange: "展开下拉菜单的回调",
    74. blur: " 移除焦点",
    75. focus: " 获取焦点",
    76. changeOnSelect: "选择时更改",
    77. displayRender: "选择后显示渲染函数",
    78. expandTrigger: "次菜单的展开方式",
    79. fieldNames: "字段名称",
    80. loadData: "动态加载选项",
    81. notFoundContent: "未找到内容",
    82. options: "可选项",
    83. popupPlacement: "浮层预设位置",
    84. popupVisible: "弹出窗口可见",
    85. showSearch: "显示搜索框",
    86. suffixIcon: "后缀图标",
    87. onPopupVisibleChange: "显示/隐藏浮层的回调",
    88. filter: "筛选条件",
    89. limit: "限制数量",
    90. matchInputWidth: "是否同宽",
    91. render: "渲染",
    92. sort: "排序",
    93. checked: "是否选中",
    94. defaultChecked: "默认状态",
    95. indeterminate: "全选属性",
    96. name: "名称",
    97. dateRender: "自定义日期单元格内容",
    98. disabledDate: "禁用日期",
    99. dropdownClassName: "额外的弹出的className",
    100. getCalendarContainer: "定义浮层的容器",
    101. locale: "国际化配置",
    102. popupStyle: "弹出样式",
    103. onPanelChange: "日历面板切换",
    104. defaultPickerValue: "默认面板日期",
    105. disabledTime: "禁用时间",
    106. format: "日期格式",
    107. renderExtraFooter: "呈现额外的页脚",
    108. showTime: "时间功能",
    109. showTimeDefaultValue: "显示时间默认值",
    110. showToday: "显示今天",
    111. onOk: "确定",
    112. monthCellContentRender: "自定义月份内容呈现",
    113. ranges: "时间范围",
    114. onCalendarChange: "待选时间更改",
    115. form: "表格",
    116. hideRequiredMark: "隐藏必需标记",
    117. labelAlign: "标签对齐",
    118. labelCol: "标签宽度",
    119. layout: "布局方式",
    120. onSubmit: "提交成功的回调",
    121. wrapperCol: " 组件宽度",
    122. colon: "显示冒号",
    123. mapPropsToFields: "将父组件属性映射到表单项上",
    124. validateMessages: "默认校验信息",
    125. onFieldsChange: "子节点变化时触发",
    126. onValuesChange: "值改变时的回调",
    127. getFieldDecorator: "双向绑定",
    128. getFieldError: "获取字段错误",
    129. getFieldsError: "获取字段错误",
    130. getFieldsValue: "获取字段值",
    131. getFieldValue: "获取字段值",
    132. isFieldsTouched: "值的收集时机",
    133. isFieldTouched: "值的收集时机",
    134. isFieldValidating:"是否在校验状态",
    135. resetFields: "重置字段",
    136. setFields: "设置控件字段",
    137. setFieldsValue: "设置控件字段值",
    138. validateFields: "校验值字段",
    139. validateFieldsAndScroll: "校验字段是否在可见范围",
    140. optionsFirst: " 每一表单校验",
    141. optionsFirstFields: " 指定表单域校验",
    142. optionsForce: " 已经校验过的表单域再次校验",
    143. optionsScroll: "滚动行为",
    144. id: "组件id",
    145. optionsGetValueFromEvent: " options.get事件的值",
    146. optionsInitialValue: " options.initial值",
    147. optionsNormalize: " options.normalize",
    148. optionsPreserve: " options.preserve",
    149. optionsRules: " options.rules",
    150. optionsTrigger: " options.trigger",
    151. optionsValidateFirst: " options.validate first",
    152. optionsValidateTrigger: " options.校验值的时机",
    153. optionsValuePropName: "值的属性",
    154. hasFeedback: "校验展示",
    155. help: "提示信息",
    156. htmlFor: " html for",
    157. label: "标签名称",
    158. required: "是否必填",
    159. validateStatus: "校验状态",
    160. enum: "枚举类型",
    161. len: " 字段长度",
    162. max: "最大长度",
    163. message: "校验文案",
    164. min: "最小长度",
    165. pattern: "正则表达式校验",
    166. transform: "转换字段值",
    167. validator: "自定义校验",
    168. whitespace: "空白",
    169. addonAfter: "前置标签",
    170. addonBefore: "后置标签",
    171. prefix: "前置图标",
    172. suffix: "后置图标",
    173. onPressEnter: "按回车",
    174. autoSize: "自适应高度",
    175. enterButton: "输入按钮",
    176. compact: "是否用紧凑模式",
    177. visibilityToggle: "是否显示切换按钮",
    178. formatter: "指定输入框格式",
    179. parser: "转换方式",
    180. precision: "数值精度",
    181. decimalSeparator: "小数点",
    182. step: "步数",
    183. split: "拆分",
    184. validateSearch: "自定义验证",
    185. allowHalf: "允许半选",
    186. character: "自定义字符",
    187. count: "star总数",
    188. tooltips: "提示信息",
    189. onHoverChange: "鼠标事件",
    190. onKeyDown: "按键回调",
    191. buttonStyle: "按钮样式",
    192. autoClearSearchValue: "清空搜索框",
    193. dropdownMatchSelectWidth: "下拉同宽",
    194. dropdownRender: "自定义下拉框内容",
    195. dropdownStyle: "下拉样式",
    196. firstActiveValue: "高亮第一个",
    197. labelInValue: "值包含内容",
    198. maxTagCount: "最大标签数",
    199. maxTagTextLength: "最大标签文本长度",
    200. maxTagPlaceholder: "最大标签占位显示内容",
    201. optionFilterProp: "过滤属性",
    202. showArrow: "是否显示下拉箭头",
    203. removeIcon: "清除图标",
    204. clearIcon: "清空图标",
    205. menuItemSelectedIcon: "当前选中条目图标",
    206. tokenSeparators: "自动分词的分隔符",
    207. onInputKeyDown: "按下输入键时的回调",
    208. onMouseEnter: "鼠标移入时回调",
    209. onMouseLeave: "鼠标移出时回调",
    210. onPopupScroll: "下拉列表滚动时回调",
    211. dots: "只能刻度上",
    212. included: "包含关系",
    213. marks: "刻度标记",
    214. range: "双滑块模式",
    215. reverse: "反向坐标轴",
    216. tipFormatter: "提示格式化程序",
    217. vertical: "垂直方向",
    218. onAfterChange: "改变后回调",
    219. tooltipPlacement: "提示信息展示位置",
    220. tooltipVisible: "提示信息的显示",
    221. getTooltipPopupContainer: "获取工具提示弹出式容器",
    222. checkedChildren: "选中时内容",
    223. unCheckedChildren: "未选中内容",
    224. filterTreeNode: "过滤属性",
    225. searchPlaceholder: "搜索占位",
    226. searchValue: "搜索框值",
    227. treeIcon: "树形图标",
    228. showCheckedStrategy: "显示节点",
    229. treeCheckable: "显示复选框",
    230. treeCheckStrictly: "节点受控",
    231. treeData: "节点配置",
    232. treeDataSimpleMode: "简单格式",
    233. treeDefaultExpandAll: "展开所有",
    234. treeDefaultExpandedKeys: "默认展开树节点",
    235. treeExpandedKeys: "展开的树节点",
    236. treeNodeFilterProp: "过滤属性",
    237. treeNodeLabelProp: "显示属性",
    238. onTreeExpand: "展开节点时调用",
    239. disableCheckbox: "禁用复选框",
    240. isLeaf: "是否叶子节点",
    241. addon: "底部显示内容",
    242. clearText: "清除文案",
    243. defaultOpenValue: "默认打开值",
    244. disabledHours: "禁选时间",
    245. disabledMinutes: "禁选分钟",
    246. disabledSeconds: "禁选秒数",
    247. hideDisabledOptions: "隐藏禁用的选项",
    248. hourStep: "小时步长",
    249. inputReadOnly: "只读",
    250. minuteStep: "分钟步长",
    251. secondStep: "秒钟步长",
    252. use12Hours: "使用12小时制",
    253. lazy: "懒",
    254. listStyle: "列表样式",
    255. operations: "操作",
    256. showSelectAll: "显示全选",
    257. targetKeys: "目标键",
    258. titles: "标题",
    259. onScroll: "滚动",
    260. onSelectChange: "按选择更改",
    261. filteredItems: "过滤属性",
    262. onItemSelect: "选择项目",
    263. onItemSelectAll: "全部选中",
    264. accept: "文件类型",
    265. action: "上传地址",
    266. directory: "上传目录",
    267. beforeUpload: "上传之前",
    268. customRequest: "自定义请求",
    269. data: "上传参数",
    270. defaultFileList: "默认列表",
    271. fileList: "文件列表",
    272. headers: "请求头部",
    273. listType: "内联样式",
    274. previewFile: "预览文件",
    275. showUploadList: "展示已上传",
    276. supportServerRender: "支持服务器渲染",
    277. withCredentials: "是否携带cookie",
    278. openFileDialogOnClick: "点击打开文件对话框",
    279. onPreview: "预览回调",
    280. onRemove : "移除回调",
    281. onDownload: "下载回调",
    282. transformFile : "转换文件",
    283. src: " 资源地址",
    284. srcSet: "响应式资源地址",
    285. alt: "替代文本",
    286. onError: "加载失败事件",
    287. color: "颜色",
    288. dot: "展示成红点",
    289. overflowCount: "封顶数字值",
    290. showZero: "数值为0 是否展示badge",
    291. text: "状态点文本",
    292. dateCellRender: "日期单元格渲染",
    293. dateFullCellRender: "日期全单元格渲染",
    294. fullscreen: "全屏展示",
    295. monthCellRender: "月单元格渲染",
    296. monthFullCellRender: "月满单元格渲染",
    297. validRange: "日期范围",
    298. headerRender: "头部渲染",
    299. actions: "卡片操作组",
    300. activeTabKey: "激活面板",
    301. headStyle: "头部样式",
    302. bodyStyle: "内容区样式",
    303. bordered: "显示边框",
    304. cover: "卡片封面",
    305. defaultActiveTabKey: "默认选中",
    306. hoverable: "悬浮",
    307. tabList: "页签标题",
    308. tabBarExtraContent: "额外内容",
    309. onTabChange: "页签切换回调",
    310. afterChange: "切换面板的回调",
    311. autoplay: "自动切换",
    312. beforeChange: "切换面板的回调",
    313. dotPosition: "面板点位置",
    314. easing: "动画效果",
    315. effect: "效果函数",
    316. goTo: "切换到指定面板",
    317. next: "切到下一面板",
    318. prev: " 切到上一面板",
    319. activeKey: "激活面板",
    320. defaultActiveKey: "选中面板",
    321. accordion: "手风琴式",
    322. expandIcon: "切换图标",
    323. expandIconPosition: "图标位置",
    324. destroyInactivePanel: "销毁面板",
    325. forceRender: "隐藏渲染",
    326. header: "面板头部",
    327. author: "作者",
    328. content: "评论内容",
    329. datetime: "日期时间",
    330. column: "列",
    331. imageStyle: "图片样式",
    332. image: "图片",
    333. grid: "网格",
    334. itemLayout: "项目布局",
    335. loadMore: "加载更多",
    336. pagination: "分页",
    337. renderItem: "渲染列表",
    338. position: "位置",
    339. groupSeparator: "千位分隔符",
    340. valueStyle: "数值样式",
    341. onFinish: "完成时触发",
    342. arrowPointAtCenter: "指向中心",
    343. autoAdjustOverflow: "自动调整溢出",
    344. defaultVisible: "默认显示",
    345. mouseEnterDelay: "鼠标进入延迟",
    346. mouseLeaveDelay: "鼠标离开延迟",
    347. tableLayout: "表格布局",
    348. childrenColumnName: "子列名称",
    349. columns: "列配置",
    350. components: "组件",
    351. defaultExpandAllRows: "默认展开",
    352. defaultExpandedRowKeys: "固定展开行",
    353. expandedRowKeys: "扩展行键",
    354. expandedRowRender: "扩展行渲染",
    355. expandRowByClick: "点击扩展",
    356. indentSize: "缩进大小",
    357. rowClassName: "行类名称",
    358. rowKey: "行键",
    359. rowSelection: "行选择",
    360. scroll: "滚动",
    361. showHeader: "显示标题",
    362. onExpand: "扩展",
    363. onExpandedRowsChange: "在扩展的行上更改",
    364. onHeaderRow: "在标题行上",
    365. onRow: "按行",
    366. colSpan: " col span",
    367. dataIndex: "数据索引",
    368. defaultSortOrder: "默认排序顺序",
    369. filterDropdown: "过滤器下拉列表",
    370. filterDropdownVisible: "可见过滤器下拉列表",
    371. filtered: "已过滤",
    372. filteredValue: "过滤值",
    373. filterIcon: "过滤器图标",
    374. filterMultiple: "过滤多个",
    375. filters: "过滤器",
    376. fixed: "固定",
    377. sorter: "分类器",
    378. sortOrder: "排序顺序",
    379. sortDirections: "排序方向",
    380. onCell: "在单元格上",
    381. onFilter: "在过滤器上",
    382. onFilterDropdownVisibleChange: "关于过滤器下拉列表的可见变化",
    383. onHeaderCell: "在标题单元格上",
    384. columnWidth: "列宽",
    385. columnTitle: "列标题",
    386. getCheckboxProps: "获取复选框道具",
    387. hideDefaultSelections: "隐藏默认选择",
    388. selectedRowKeys: "选定的行键",
    389. selections: "选择",
    390. onSelectAll: "全选",
    391. onSelectInvert: "在选择反转时",
    392. x: "横向滚动",
    393. y: "纵向滚动",
    394. scrollToFirstRowOnChange: "滚动到更改后的第一行",
    395. animated: "动画",
    396. renderTabBar: "渲染选项卡栏",
    397. hideAdd: "隐藏添加",
    398. tabBarGutter: "标签栏装订线",
    399. tabBarStyle: "标签栏样式",
    400. tabPosition: "标签位置",
    401. onEdit: "在编辑中",
    402. onNextClick: "下次点击",
    403. onPrevClick: "按一下",
    404. onTabClick: "单击选项卡",
    405. tab: "显示文字",
    406. afterClose: "关闭后",
    407. closable: "可关闭",
    408. onClose: "关闭",
    409. pending: "待处理",
    410. pendingDot: "待定点",
    411. autoExpandParent: "自动扩展父级",
    412. blockNode: "块节点",
    413. checkable: "可检查",
    414. checkedKeys: "选中的键",
    415. checkStrictly: "严格检查",
    416. defaultCheckedKeys: "默认选中的密钥",
    417. defaultExpandAll: "默认全部展开",
    418. defaultExpandedKeys: "默认扩展键",
    419. defaultExpandParent: "默认扩展父级",
    420. draggable: "可拖动",
    421. expandedKeys: "扩展键",
    422. loadedKeys: "已加载的密钥",
    423. showIcon: "显示图标",
    424. switcherIcon: "切换器图标",
    425. showLine: "显示行",
    426. onCheck: "在支票上",
    427. onDragEnd: "在拖尾",
    428. onDragEnter: "在拖动进入",
    429. onDragLeave: "在拖假期间",
    430. onDragOver: "拖曳",
    431. onDragStart: "在拖动开始",
    432. onDrop: "放下",
    433. onLoad: "正在加载",
    434. onRightClick: "单击右键",
    435. expandAction: "展开动作",
    436. banner: "顶部公告",
    437. closeText: "自定义关闭",
    438. destroyOnClose: "销毁子元素",
    439. getContainer: "挂载节点",
    440. maskClosable: "是否蒙层",
    441. mask: "是否遮罩",
    442. maskStyle: "遮罩样式",
    443. drawerStyle: "弹出层样式",
    444. headerStyle: "头部样式",
    445. zIndex: "层级",
    446. afterVisibleChange: "切换结束时的回调",
    447. keyboard: "支持esc关闭",
    448. cancelText: "取消文字",
    449. centered: "居中展示",
    450. closeIcon: "自定义关闭图标",
    451. confirmLoading: "确认加载",
    452. okText: "确认文字",
    453. okType: "确认类型",
    454. okButtonProps: "ok 按钮 props",
    455. cancelButtonProps: "cancel按钮props",
    456. wrapClassName: "外层容器类名",
    457. onCancel: "关闭时的回调",
    458. autoFocusButton: "自动对获取焦点",
    459. iconType: "图标类型",
    460. duration: "是否延时",
    461. maxCount: "最大数量",
    462. top: "距顶部位置",
    463. btn: "关闭按钮",
    464. bottom: "距底部位置",
    465. percent: "百分比",
    466. showInfo: "是否显示信息",
    467. strokeLinecap: "笔画线帽",
    468. strokeColor: "颜色",
    469. successPercent: "完成百分比",
    470. onConfirm: "确认的回调",
    471. delay: "延迟显示",
    472. indicator: "指示符",
    473. spinning: "加载状态",
    474. tip: "描述文案",
    475. wrapperClassName: "包装器类属性",
    476. active: "是否展示动画",
    477. paragraph: "是否显示段落",
    478. rows: "行数",
    479. affix: "是否浮动",
    480. bounds: "锚点边界",
    481. showInkInFixed: "固定显示",
    482. getCurrentAnchor: "获取当前锚点",
    483. targetOffset: "偏移量",
    484. visibilityHeight: "可见高度",
    485. autoInsertSpaceInButton: "是否移除空格",
    486. csp: " csp配置",
    487. renderEmpty: "空状态",
    488. prefixCls: "统一前缀",
    489. pageHeader: "页面标题",
    490. dashed: "是否为虚线",
    491. orientation: "标题位置",
    492. getMentions: "获得提及",
    493. toContentState: "到内容状态",
    494. toString: "转字符串",
    495. defaultSuggestions: "默认内容",
    496. getSuggestionContainer: "获取建议容器",
    497. multiLines: "多行模式",
    498. readOnly: "是否只读",
    499. suggestions: "建议内容",
    500. suggestionStyle: "下拉框样式",
    501. onSearchChange: "根据搜索变化"
    502. }
    503. for(let name in der){
    504. for (let componentApi of componentApis){
    505. if(componentApi.name === name){
    506. componentApi.label = der[name]
    507. }
    508. //componentApi.label = componentApi.name === name ? der[name] : '-'
    509. //console.log(componentApi.label,'componentApi.label')
    510. }
    511. if(subComponents.length>0){
    512. for(let subComponent of subComponents){
    513. for (let componentApi of subComponent.apis){
    514. if(componentApi.name === name){
    515. componentApi.label = der[name]
    516. }
    517. //componentApi.label = componentApi.name === name ? der[name] : '-'
    518. }
    519. }
    520. }
    521. }
    522. Object.assign(component,{apis:componentApis},{subComponents:subComponents})
    523. } catch(e) {
    524. console.error('---1')
    525. }
    526. }
    527. let file = path.join(__dirname, 'souce_components.json');
    528. fs.writeFileSync(file, JSON.stringify(componentList), (err)=>{
    529. if(err){
    530. return console.log(err)
    531. }
    532. console.log('文件创建成功,地址:' + file);
    533. })
    534. res.send('数据获取并保存成功')
    535. });

    学习链接