{"id":13655151,"url":"https://github.com/iconfont-cli/remax-iconfont-cli","last_synced_at":"2025-07-04T06:37:56.340Z","repository":{"id":42891671,"uuid":"254081133","full_name":"iconfont-cli/remax-iconfont-cli","owner":"iconfont-cli","description":"在RemaxJs框架中使用iconfont图标，支持多端，支持多色彩，不依赖字体。","archived":false,"fork":false,"pushed_at":"2023-07-10T19:58:01.000Z","size":64,"stargazers_count":31,"open_issues_count":7,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-11T14:19:55.352Z","etag":null,"topics":["iconfont","iconfont-remax","iconfont-remaxjs","remax-iconfont","remaxjs","remaxjs-iconfont"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iconfont-cli.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-04-08T12:26:51.000Z","updated_at":"2023-06-30T00:50:54.000Z","dependencies_parsed_at":"2024-01-14T16:11:08.481Z","dependency_job_id":"a61e4f0c-af8d-40f2-877e-d6c4c2ac97c6","html_url":"https://github.com/iconfont-cli/remax-iconfont-cli","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iconfont-cli%2Fremax-iconfont-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iconfont-cli%2Fremax-iconfont-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iconfont-cli%2Fremax-iconfont-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iconfont-cli%2Fremax-iconfont-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iconfont-cli","download_url":"https://codeload.github.com/iconfont-cli/remax-iconfont-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248684285,"owners_count":21145051,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["iconfont","iconfont-remax","iconfont-remaxjs","remax-iconfont","remaxjs","remaxjs-iconfont"],"created_at":"2024-08-02T03:00:58.689Z","updated_at":"2025-04-13T08:33:24.224Z","avatar_url":"https://github.com/iconfont-cli.png","language":"JavaScript","funding_links":[],"categories":["目录"],"sub_categories":["组件"],"readme":"# remax-iconfont-cli\n在RemaxJs框架中使用iconfont图标，不依赖字体，支持多色彩。\n\n# 支持平台\n\n* 微信小程序\n* 支付宝小程序\n* 头条小程序\n\n# 特性\n1、一键生成标准组件，多端支持\n\u003cbr\u003e\n2、使用方便，import即可\n\u003cbr\u003e\n3、支持多色彩\n\u003cbr\u003e\n4、支持自定义颜色\n\u003cbr\u003e\n5、支持es6和typescript两种模式\n\n# Step 1\n安装插件\n```bash\n# Yarn\nyarn add remax-iconfont-cli --dev\n\n# Npm\nnpm install remax-iconfont-cli --save-dev\n```\n\n\n# Step 2\n生成配置文件\n```bash\nnpx iconfont-init\n\n# 可传入配置输出路径\n# npx iconfont-init --output iconfont.json\n```\n此时项目根目录会生成一个`iconfont.json`的文件，内容如下：\n```json\n{\n  \"symbol_url\": \"请参考README.md，复制 http://iconfont.cn 官网提供的JS链接\",\n  \"save_dir\": \"./src/components/iconfont\",\n  \"use_typescript\": false,\n  \"platforms\": \"*\",\n  \"use_rpx\": true,\n  \"trim_icon_prefix\": \"icon\",\n  \"default_icon_size\": 18\n}\n```\n### 配置参数说明：\n### symbol_url\n请直接复制[iconfont](http://iconfont.cn)官网提供的项目链接。请务必看清是`.js`后缀而不是.css后缀。如果你现在还没有创建iconfont的仓库，那么可以填入这个链接去测试：`http://at.alicdn.com/t/font_1373348_kk9y3jk2omq.js`\n\n\u003cbr /\u003e\n\n![](https://github.com/fwh1990/mini-program-iconfont-cli/blob/master/images/symbol-url.png?raw=true)\n\n### save_dir\n根据iconfont图标生成的组件存放的位置。每次生成组件之前，该文件夹都会被清空。\n\n### use_typescript\n如果您的项目使用Typescript编写，请设置为true。这个选项将决定生成的图标组件是`.tsx`还是`.js`后缀。\n\n当该值为false时，我们会为您的图标生成`.js`和`.d.ts`两个文件，以便您能享受到最好的开发体验。\n\n### platforms\n选择需要支持的平台，默认是`*`，意味着所有平台都需要支持（如果有）。如果你只想支持部分平台，也可以设置成数组：\n```json5\n{\n  // 选择你需要的平台\n  \"platforms\": [\"wechat\", \"ali\", \"toutiao\"]\n}\n```\n\n### use_rpx\n是否使用[尺寸单位rpx](https://developers.weixin.qq.com/miniprogram/dev/framework/view/wxss.html#%E5%B0%BA%E5%AF%B8%E5%8D%95%E4%BD%8D)还是普通的像素单位`px`。默认值为true，与RemaxJs保持一致的缩放。您也可以设置为false，强制使用`px`\n\n--------\n\n**注意：** 无论您是否设置了use_rpx，传入的size值都是`px单位`。如果开启了use_rpx，组件内部会帮您自动转换。\n\n### trim_icon_prefix\n如果你的图标有通用的前缀，而你在使用的时候又不想重复去写，那么可以通过这种配置这个选项把前缀统一去掉。\n\n### default_icon_size\n我们将为每个生成的图标组件加入默认的字体大小，当然，你也可以通过传入props的方式改变这个size值。\n\n# Step 3\n开始生成RemaxJs标准组件\n```bash\nnpx iconfont-remax\n\n# 可传入配置文件路径\n# npx iconfont-remax --config iconfont.json\n```\n生成后查看您设置的保存目录中是否含有所有的图标\n\n-------\n\n在生成代码之前，你可以顺便参考[snapshots目录](https://github.com/iconfont-cli/remax-iconfont-cli/tree/master/snapshots)自动生成的快照文件。\n\n# 使用\n在Page中使用图标\n```jsx harmony\nimport React, { Component } from 'react';\nimport IconFont from '../components/iconfont';\n\nclass App extends Component {\n  render() {\n    return \u003cIconFont name=\"alipay\" /\u003e;\n  }\n}\n\nexport default App;\n```\n更多用法：\n```jsx harmony\n// 原色彩\n\u003cIconFont name=\"alipay\" /\u003e\n\n// 单色：红色\n\u003cIconFont name=\"alipay\" color=\"red\" /\u003e\n\n// 多色：红色+橘色\n\u003cIconFont name=\"alipay\" color={['red', 'orange']} size={300} /\u003e\n\n// 不同格式的颜色写法\n\u003cIconFont name=\"alipay\" color={['#333', 'rgb(50, 124, 39)']} /\u003e\n\n\n// 与文字对齐\n\u003cView style={{ display: 'flex', alignItems: 'center' }}\u003e\n  \u003cText\u003eHello\u003c/text\u003e\n  \u003cIconFont name=\"alipay\" /\u003e\n\u003c/View\u003e\n```\n\n# 更新图标\n当您在iconfont.cn中的图标有变更时，只需更改配置`symbol_url`，然后再次执行`Step 3`即可生成最新的图标组件\n```bash\n# 修改 symbol_url 配置后执行：\nnpx iconfont-remax\n```\n\n# 扩展\n|平台|库|\n|----|---|\n|小程序|[mini-program-iconfont-cli](https://github.com/fwh1990/mini-program-iconfont-cli)|\n|React Native|[react-native-iconfont-cli](https://github.com/fwh1990/react-native-iconfont-cli)|\n|React H5|[react-iconfont-cli](https://github.com/fwh1990/react-iconfont-cli)|\n|Flutter|[flutter-iconfont-cli](https://github.com/fwh1990/flutter-iconfont-cli)|\n|Taro|[taro-iconfont-cli](https://github.com/fwh1990/taro-iconfont-cli)|\n\n--------\n\n欢迎使用，并给我一些反馈和建议，让这个库做的更好\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficonfont-cli%2Fremax-iconfont-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ficonfont-cli%2Fremax-iconfont-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficonfont-cli%2Fremax-iconfont-cli/lists"}