{"id":18938251,"url":"https://github.com/wechat-miniprogram/kbone-template-preact","last_synced_at":"2025-04-15T19:30:22.849Z","repository":{"id":42440787,"uuid":"205974153","full_name":"wechat-miniprogram/kbone-template-preact","owner":"wechat-miniprogram","description":"a simple preact template for kbone","archived":false,"fork":false,"pushed_at":"2022-04-06T02:13:22.000Z","size":421,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-29T01:12:13.122Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wechat-miniprogram.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-03T02:37:16.000Z","updated_at":"2024-08-14T02:22:19.000Z","dependencies_parsed_at":"2022-09-09T16:31:29.659Z","dependency_job_id":null,"html_url":"https://github.com/wechat-miniprogram/kbone-template-preact","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/wechat-miniprogram%2Fkbone-template-preact","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechat-miniprogram%2Fkbone-template-preact/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechat-miniprogram%2Fkbone-template-preact/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechat-miniprogram%2Fkbone-template-preact/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wechat-miniprogram","download_url":"https://codeload.github.com/wechat-miniprogram/kbone-template-preact/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249138500,"owners_count":21218898,"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-11-08T12:13:53.568Z","updated_at":"2025-04-15T19:30:22.533Z","avatar_url":"https://github.com/wechat-miniprogram.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# preact-kbone\n\n使用 [preact](https://github.com/preactjs/preact) 多端开发(小程序和Web)，基于 [kbone](https://github.com/Tencent/kbone) 的 element 和 render。\n\n## 特性\n\n* 使用最好的 react web 框架 preact，轻量迅速（react 不是最好的 react web 框架）\n* 由于 3kb preact 加持，生成出的包大小超级小！！\n\n## 一套语法多端运行\n\n```jsx\nimport { h } from 'preact'\nimport { useState } from 'preact/hooks'\nimport './index.css'\n\nfunction Counter() {\n  const [count, setCount] = useState(0)\n  return (\n    \u003cdiv\u003e\n      \u003cbutton onClick={() =\u003e setCount(count - 1)}\u003e-\u003c/button\u003e\n      \u003cspan\u003e{count}\u003c/span\u003e\n      \u003cbutton onClick={() =\u003e setCount(count + 1)}\u003e+\u003c/button\u003e\n      \u003cdiv onClick={clickHandle}\u003e跳转\u003c/div\u003e\n    \u003c/div\u003e\n  )\n}\n\nfunction clickHandle() {\n  if ('undefined' != typeof wx \u0026\u0026 wx.getSystemInfoSync) {\n    wx.navigateTo({\n      url: '../log/index?id=1',\n    })\n  } else {\n    location.href = 'log.html'\n  }\n}\n\nexport default Counter\n```\n\n## 快速开始\n\n```\nnpx kbone-cli init my-app\ncd my-app\nnpm run mp        // 开发小程序\nnpm run build:mp  // 构建小程序\nnpm run web       // 开发 web\nnpm run build     // 构建 web\n```\n\n## 目录说明\n\n```\n├─ dist\n│  ├─ mp     // 微信开发者工具指向的目录，用于生产环境\n│  ├─ web    // web 编译出的文件，用于生产环境\n├─ build     // 构建相关\n├─ src\n│  ├─ assets\n│  ├─ components     // 存放所有组件\n│  ├─ log.jsx        // 入口文件，会 build 成 log.html\n│  └─ index.jsx      // 入口文件，会 build 成 index.html\n```\n\n## 注意事项\n\npreact 并没有提供根组件实例的销毁方法（如 vue.$destroy），所以在多页应用中页面关闭时不会触发该页面组件的 componentWillUnmount 钩子。开发者可自行监听 wxunload 或 beforeunload 事件来进行页面的销毁工作，比如调用 render 方法渲染一个空节点，强行触发页面组件的 componentWillUnmount 钩子。\n\n## 谁在使用 kbone？\n\n\u003ctable\u003e\n\t\u003ctbody\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003ctd\u003e\u003ca target=\"_blank\" href=\"https://developers.weixin.qq.com/community/develop/mixflow\"\u003e\u003cimg width=\"200px\"\n\t\t\t\t\t\tsrc=\"https://raw.githubusercontent.com/wechat-miniprogram/kbone/develop/docs/images/code1.jpg\"\u003e\u003c/a\u003e\u003c/td\u003e\n\t\t\t\u003ctd\u003e\u003ca target=\"_blank\" href=\"https://tencent.github.io/omi/\"\u003e\u003cimg width=\"200px\"\n\t\t\t\t\t\tsrc=\"https://github.com/Tencent/omi/raw/master/assets/omi-cloud.jpg\"\u003e\u003c/a\u003e\u003c/td\u003e\n\t\t\t\u003ctd width=\"92px\"\u003e\u003ca target=\"_blank\" href=\"https://github.com/Tencent/omi/issues/new\"\u003e告诉我们\u003c/a\u003e\u003c/td\u003e\n\t\t\n\u003c/table\u003e\n\n## License\n\nMIT \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwechat-miniprogram%2Fkbone-template-preact","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwechat-miniprogram%2Fkbone-template-preact","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwechat-miniprogram%2Fkbone-template-preact/lists"}