{"id":13603944,"url":"https://github.com/NervJS/taro-zhihu-sample","last_synced_at":"2025-04-11T22:32:08.844Z","repository":{"id":34157059,"uuid":"139847594","full_name":"NervJS/taro-zhihu-sample","owner":"NervJS","description":"a demo based on taro","archived":false,"fork":false,"pushed_at":"2023-03-04T04:13:11.000Z","size":4282,"stargazers_count":345,"open_issues_count":24,"forks_count":91,"subscribers_count":23,"default_branch":"next","last_synced_at":"2024-08-02T19:33:00.193Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/NervJS.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}},"created_at":"2018-07-05T12:39:22.000Z","updated_at":"2024-06-24T15:25:52.000Z","dependencies_parsed_at":"2024-02-01T15:34:58.288Z","dependency_job_id":null,"html_url":"https://github.com/NervJS/taro-zhihu-sample","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NervJS%2Ftaro-zhihu-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NervJS%2Ftaro-zhihu-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NervJS%2Ftaro-zhihu-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NervJS%2Ftaro-zhihu-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NervJS","download_url":"https://codeload.github.com/NervJS/taro-zhihu-sample/tar.gz/refs/heads/next","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223483659,"owners_count":17152819,"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":[],"created_at":"2024-08-01T19:00:36.948Z","updated_at":"2024-11-07T08:30:37.451Z","avatar_url":"https://github.com/NervJS.png","language":"JavaScript","funding_links":[],"categories":["示例项目","JavaScript"],"sub_categories":["Taro 2"],"readme":"### Taro简介\nTaro 是由凹凸实验室打造的一套遵循 React 语法规范的多端统一开发框架。\n\n使用 Taro，我们可以只书写一套代码，再通过 Taro 的编译工具，将源代码分别编译出可以在不同端（微信小程序、H5、App 端等）运行的代码。目前Taro支持编译出支持微信小程序、H5运行的代码，RN和支付宝小程序的支持还在开发中。具体介绍请看这篇[文章](https://aotu.io/notes/2018/06/07/Taro/)，[github地址](https://github.com/NervJS/taro)\n\n### 前言\n为了学习Taro，本人在github找了[知乎的小程序demo](https://github.com/RebeccaHanjw/weapp-wechat-zhihu)，本文通过修改该份代码，实现了taro版的知乎H5、小程序demo，对taro有兴趣的同学可以star或fork下来学习，[github地址](https://github.com/jimczj/taro_zhihu)。\n\n### 安装\n安装 Taro 开发工具 @tarojs/cli\n\n使用 npm 或者 yarn 全局安装\n\n```\nnpm install -g @tarojs/cli\n// 或\nyarn global add @tarojs/cli\n```\n下载代码\n```\ngit clone https://github.com/jimczj/taro_zhihu\n# 安装依赖\ncd taro_zhihu\nnpm i\n```\n\n### 使用\n\n文件目录如下：\n```\n├── dist                   编译结果目录\n├── config                 配置目录\n|   ├── dev.js             开发时配置\n|   ├── index.js           默认配置\n|   └── prod.js            打包时配置\n├── src                    源码目录\n|   ├── pages              页面文件目录\n|   |   ├── index          index页面目录\n|   |   |   ├── index.js   index页面逻辑\n|   |   |   └── index.css  index页面样式\n|   ├── app.css            项目总通用样式\n|   └── app.js             项目入口文件\n└── package.json\n```\n进入项目目录开始开发，可以选择小程序预览模式，或者h5预览模式，若使用微信小程序预览模式，则需要自行下载并打开[微信开发者工具](https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html)，选择预览项目根目录。\n\n**微信小程序编译预览模式:**\n\n\n```\n# npm script\nnpm run dev:weapp\n# 或 仅限全局安装\ntaro build --type weapp --watch\n```\n\n**H5编译预览模式:**\n```\n# npm script\nnpm run dev:h5\n# 或 仅限全局安装\ntaro build --type h5 --watch\n```\n### 页面展示\n\n![](https://user-gold-cdn.xitu.io/2018/6/15/16402e6037be17b7?w=648\u0026h=1142\u0026f=jpeg\u0026s=189658)\n![](https://user-gold-cdn.xitu.io/2018/6/15/16402e624c0690f7?w=696\u0026h=1154\u0026f=jpeg\u0026s=223080)\n![](https://user-gold-cdn.xitu.io/2018/6/15/16402e640f51f37d?w=656\u0026h=1146\u0026f=jpeg\u0026s=147204)\n![](https://user-gold-cdn.xitu.io/2018/6/15/16402e65960247b6?w=656\u0026h=1146\u0026f=jpeg\u0026s=147204)\n![](https://user-gold-cdn.xitu.io/2018/6/15/16402e6774a05521?w=656\u0026h=1138\u0026f=jpeg\u0026s=200522)\n![](https://user-gold-cdn.xitu.io/2018/6/15/16402e68a9ca8235?w=660\u0026h=1150\u0026f=jpeg\u0026s=80253)\n\n\n### 开发前注意\n若使用 微信小程序预览模式 ，则需下载并使用[微信开发者工具](https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html)添加项目进行预览，此时需要注意微信开发者工具的项目设置\n* 需要设置关闭ES6转ES5功能，开启可能报错\n* 需要设置关闭上传代码时样式自动补全，开启可能报错\n* 需要设置关闭代码压缩上传，开启可能报错\n\n\n![项目设置](https://user-gold-cdn.xitu.io/2018/6/14/163fe817af30c48e?w=2170\u0026h=1080\u0026f=jpeg\u0026s=198269)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNervJS%2Ftaro-zhihu-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FNervJS%2Ftaro-zhihu-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNervJS%2Ftaro-zhihu-sample/lists"}