{"id":20563490,"url":"https://github.com/thundersdata-frontend/taro-template","last_synced_at":"2026-03-16T12:33:07.186Z","repository":{"id":99406581,"uuid":"254580563","full_name":"thundersdata-frontend/taro-template","owner":"thundersdata-frontend","description":"taro项目模板","archived":false,"fork":false,"pushed_at":"2023-07-07T21:30:21.000Z","size":1313,"stargazers_count":1,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-14T14:57:24.729Z","etag":null,"topics":["hooks","taro","taro-ui","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thundersdata-frontend.png","metadata":{"files":{"readme":"readMe.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-04-10T08:14:33.000Z","updated_at":"2022-05-25T05:02:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"a602de46-eef0-448c-bda8-2c658a8af94b","html_url":"https://github.com/thundersdata-frontend/taro-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/thundersdata-frontend/taro-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thundersdata-frontend%2Ftaro-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thundersdata-frontend%2Ftaro-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thundersdata-frontend%2Ftaro-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thundersdata-frontend%2Ftaro-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thundersdata-frontend","download_url":"https://codeload.github.com/thundersdata-frontend/taro-template/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thundersdata-frontend%2Ftaro-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279003294,"owners_count":26083555,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["hooks","taro","taro-ui","typescript"],"created_at":"2024-11-16T04:19:02.562Z","updated_at":"2025-10-10T08:07:28.460Z","avatar_url":"https://github.com/thundersdata-frontend.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\n * @文件描述:\n * @公司: thundersdata\n * @作者: 廖军\n * @Date: 2020-02-19 17:24:13\n * @LastEditors: 阮旭松\n * @LastEditTime: 2020-04-18 14:42:58\n --\u003e\n\n### pont 适配与改进\n\n1. 避免全局暴露 API，推荐使用引入的方式；\n2. 原先的 request 请求不适用于小程序，基于 taro 重新封装了 taro-request 方法文件并修改 pontTemplate 的生成方法；\n3. pontTemplate 的生成方法中添加了对接口返回值传递的 interface 字符拼接；\n\n### taro 其他需要注意的地方\n\n1. 全局变量在小程序中以 global 的声明存在，而不是 window，对应的 lodash 和之前的全局保存参数的方式都要修改；\n2. 添加自定义组件的时候，涉及全局样式，需要添加 option addGlobalClass 为 true 才能生效；\n3. iceStore 本身依赖 react，所以需要更改源码来适配 taro，并且不能使用最新版本，最新版本需要 Provider 才能使用，同样不适用 taro；\n4. taro 有自身封装的一些本地存储等方法；\n5. taro 的路由配置在 app.ts config.pages 中；\n6. 如果有一些需要定制的组件可以先到物料市场看一下（当然也要做个评估再用，不好用就自己定制）：https://taro-ext.jd.com/\n7. iceStore useStore 方法依赖与 hooks 方法，在不同的平台下，需要引入对应的 taro 包，否则会报错的；\n8. taro 可支持 JSX 的组件间传递，但是元素传入 JSX 的属性名必须以 render 开头如: renderHeader；\n9. taro 目前不支持 Fragments；\n10. taro ScrollView onRefresherRefresh 方法可被触发的前提条件是内容区可滚动且开启 refresherEnabled ，同时可用 refresherTriggered 控制 refresh 状态，配合 useRefresh 函数使用；\n11. taro 向自定义组件传递 class 可以用 externalClasses = ['my-class']的方式，可以参考 https://nervjs.github.io/taro/docs/component-style.html#%E5%A4%96%E9%83%A8%E6%A0%B7%E5%BC%8F%E7%B1%BB\n12. my-class 方法在 h5 环境会有问题，需要再添加一个 props['my-class']来兼容；\n13. 要设置底部TabBar的徽标显示可在 custom-tab-bar 文件中先设置 tab-bar 对应的 badgeField 作为 badge 字段名，再在 state 中维护。若要修改则调用在 utils/object 中的 setTabBarState 函数修改对应的 badgeField 字段的属性值，若情况较复杂可保存在本地缓存。\n14. 在 Taro 中，JS 代码里必须书写单引号，特别是 JSX 中，如果出现双引号，可能会导致编译错误。\n\n### 微信小程序需要注意的地方\n\n1. 要下载微信开发者工具配合使用，需要设置关闭 ES6 转 ES5 功能，关闭上传代码时样式自动补全，关闭代码压缩上传配置，否则可能报错。\n2. 后台接口调试，需要把域名配置到微信小程序的域名信息里面；\n3. 微信小程序的 appid 在 project.config.json 中配置；\n4. 小程序的 wxss 文件 font-face 的 url 不接受 http 地址作为参数;\n5. 微信小程序中必须使用经过配置的 https 合法域名，但在开发环境可以通过开发者工具打开本地设置，勾选“不校验合法域名……”使用测试环境接口地址；\n6. 小程序对打包文件大小有较高的要求，对应的解决方案可以先进行分包处理、通过 webpack 压缩打包代码、上传图片到云端等方法解决；\n7. 微信各类授权窗口是自带的，开发者工具和真机上显示的可能会不一样；\n8. 图片等资源路径，不能含中文，否则在真机上无法显示，但在开发者工具上是正常的；\n9. 登录: 微信小程序现在需要用点击 openType=\"getPhoneNumber\" 按钮回调的方式来获取手机号加密信息进而向后端请求解密手机号，要获取用户信息则用 openType=\"getUserInfo\" 的按钮,Taro.getUserInfo 方法将被微信废弃。\n10. 登录: 最好把 session_key 保存在后端，如果保存在前端会有多端登录 session_key 失效的问题。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthundersdata-frontend%2Ftaro-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthundersdata-frontend%2Ftaro-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthundersdata-frontend%2Ftaro-template/lists"}