omi/README.CN.md

1206 lines
57 KiB
Markdown
Raw Normal View History

2019-05-26 09:08:12 +08:00
[English](./README.md) | 简体中文
2018-10-15 10:19:45 +08:00
2020-04-26 22:30:14 +08:00
<p align="center"><img src="https://tencent.github.io/omi/assets/logo.svg" alt="omi" width="100"/></p>
2020-04-26 22:16:29 +08:00
<p align="center"><img src="https://tencent.github.io/omi/assets/omi-v6.jpg" alt="omi" width="1000"/></p>
2019-05-10 08:15:53 +08:00
<h2 align="center">Omi - 前端跨框架跨平台框架</h2>
2019-11-17 09:54:41 +08:00
<p align="center"><b>基于 Web Components 并支持 IE8+(omio),小程序(omi-kbone) 和 任意前端框架集成</b></p>
2018-10-15 09:45:24 +08:00
2020-04-24 18:43:58 +08:00
## Omiu
2020-04-26 20:12:04 +08:00
> Omi 打造的跨框架、[跨主题](https://tencent.github.io/omi/components/docs/cn.html#/theme?index=0&subIndex=1) UI 组件库
2020-04-24 18:43:58 +08:00
| **Name** | **Status** | **Example** | **Docs** |
| -------------- | ----------|----------- | ----------------|
| [@omiu/button][omiu-button-github] | [![omiu-button-status]][omiu-button-package]|[CodePen][omiu-button-codepen] | [Button Docs][omiu-button-docs]|
| [@omiu/icon][omiu-icon-github] | [![omiu-icon-status]][omiu-icon-package]|[Icon Online][omiu-icon-codepen] | [Icon Docs][omiu-icon-docs]|
| [@omiu/tabs][omiu-tabs-github] | [![omiu-tabs-status]][omiu-tabs-package]|[CodePen][omiu-tabs-codepen] | [Tabs Docs][omiu-tabs-docs]|
| [@omiu/radio][omiu-radio-github] | [![omiu-radio-status]][omiu-radio-package]|[CodePen][omiu-radio-codepen] | [Radio Docs][omiu-radio-docs]|
| [@omiu/link][omiu-link-github] | [![omiu-link-status]][omiu-link-package]|[CodePen][omiu-link-codepen] | [Link Docs][omiu-link-docs]|
| [@omiu/checkbox][omiu-checkbox-github] | [![omiu-checkbox-status]][omiu-checkbox-package]|[CodePen][omiu-checkbox-codepen] | [Checkbox Docs][omiu-checkbox-docs]|
2020-04-26 17:11:25 +08:00
| [@omiu/hamburger-menu][omiu-hamburger-menu-github] | [![omiu-hamburger-menu-status]][omiu-hamburger-menu-package]|[CodePen][omiu-hamburger-menu-codepen] | [HamburgerMenu Docs][omiu-hamburger-menu-docs]|
2020-04-25 17:47:35 +08:00
| [@omiu/input][omiu-input-github] | [![omiu-input-status]][omiu-input-package]|[CodePen][omiu-input-codepen] | [Input Docs][omiu-input-docs]|
2020-04-25 21:04:53 +08:00
| [@omiu/tree][omiu-tree-github] | [![omiu-tree-status]][omiu-tree-package]|[CodePen][omiu-tree-codepen] | [Tree Docs][omiu-tree-docs]|
2020-04-26 11:17:20 +08:00
| [@omiu/pagination][omiu-pagination-github] | [![omiu-pagination-status]][omiu-pagination-package]|[CodePen][omiu-pagination-codepen] | [Pagination Docs][omiu-pagination-docs]|
2020-04-25 21:40:39 +08:00
| [@omiu/loading][omiu-loading-github] | [![omiu-loading-status]][omiu-loading-package]|[CodePen][omiu-loading-codepen] | [Loading Docs][omiu-loading-docs]|
2020-04-26 09:19:32 +08:00
| [@omiu/toast][omiu-toast-github] | [![omiu-toast-status]][omiu-toast-package]|[CodePen][omiu-toast-codepen] | [Toast Docs][omiu-toast-docs]|
2020-04-26 17:11:25 +08:00
| [@omiu/action-sheet][omiu-action-sheet-github] | [![omiu-action-sheet-status]][omiu-action-sheet-package]|[CodePen][omiu-action-sheet-codepen] | [ActionSheet Docs][omiu-action-sheet-docs]|
2020-04-26 17:43:01 +08:00
| [@omiu/switch][omiu-switch-github] | [![omiu-switch-status]][omiu-switch-package]|[CodePen][omiu-switch-codepen] | [Switch Docs][omiu-switch-docs]|
2020-04-26 20:15:59 +08:00
| [@omiu/color-picker][omiu-color-picker-github] | [![omiu-color-picker-status]][omiu-color-picker-package]|[CodePen][omiu-color-picker-codepen] | [ColorPicker Docs][omiu-color-picker-docs]|
2020-04-27 09:16:40 +08:00
| [@omiu/chart][omiu-chart-github] | [![omiu-chart-status]][omiu-chart-package]|[CodePen][omiu-chart-codepen] | [Chart Docs][omiu-chart-docs]|
2020-04-27 17:54:41 +08:00
| [@omiu/toggle-icon][omiu-toggle-icon-github] | [![omiu-toggle-icon-status]][omiu-toggle-icon-package]|[CodePen][omiu-toggle-icon-codepen] | [ToggleIcon Docs][omiu-toggle-icon-docs]|
2020-04-28 19:46:50 +08:00
| [@omiu/o-icon][omiu-o-icon-github] | [![omiu-o-icon-status]][omiu-o-icon-package]|[CodePen][omiu-o-icon-codepen] | [OIcon Docs][omiu-o-icon-docs]|
| [@omiu/badge][omiu-badge-github] | [![omiu-badge-status]][omiu-badge-package]|[CodePen][omiu-badge-codepen] | [Badge Docs][omiu-badge-docs]|
| [@omiu/avatar][omiu-avatar-github] | [![omiu-avatar-status]][omiu-avatar-package]|[CodePen][omiu-avatar-codepen] | [Avatar Docs][omiu-avatar-docs]|
2020-04-29 19:28:55 +08:00
| [@omiu/breadcrumb][omiu-breadcrumb-github] | [![omiu-breadcrumb-status]][omiu-breadcrumb-package]|[CodePen][omiu-breadcrumb-codepen] | [Breadcrumb Docs][omiu-breadcrumb-docs]|
2020-04-30 09:25:53 +08:00
| [@omiu/bottom-nav][omiu-bottom-nav-github] | [![omiu-bottom-nav-status]][omiu-bottom-nav-package]|[CodePen][omiu-bottom-nav-codepen] | [BottomNav Docs][omiu-bottom-nav-docs]|
2020-05-01 20:37:35 +08:00
| [@omiu/transition][omiu-transition-github] | [![omiu-transition-status]][omiu-transition-package]|[CodePen][omiu-transition-codepen] | [Transition Docs][omiu-transition-docs]|
2020-05-03 18:45:41 +08:00
| [@omiu/dialog][omiu-dialog-github] | [![omiu-dialog-status]][omiu-dialog-package]|[CodePen][omiu-dialog-codepen] | [Dialog Docs][omiu-dialog-docs]|
2020-05-04 16:37:36 +08:00
| [@omiu/dialog-extention][omiu-dialog-extention-github] | [![omiu-dialog-extention-status]][omiu-dialog-extention-package]|[CodePen][omiu-dialog-extention-codepen] | [DialogExtention Docs][omiu-dialog-extention-docs]|
2020-04-24 18:43:58 +08:00
| Coming... | | | |
| Coming... | | | |
[omiu-button-github]: https://github.com/Tencent/omi/tree/master/components/button
[omiu-button-status]: https://img.shields.io/npm/v/@omiu/button.svg
[omiu-button-package]: https://www.npmjs.com/package/@omiu/button
2020-04-26 21:18:25 +08:00
[omiu-button-docs]: https://tencent.github.io/omi/components/docs/cn.html#/button
2020-04-24 18:43:58 +08:00
[omiu-button-codepen]: https://codepen.io/omijs/pen/LYppwYG
[omiu-icon-github]: https://github.com/Tencent/omi/tree/master/components/icon
[omiu-icon-status]: https://img.shields.io/npm/v/@omiu/icon.svg
[omiu-icon-package]: https://www.npmjs.com/package/@omiu/icon
2020-04-26 21:18:25 +08:00
[omiu-icon-docs]: https://tencent.github.io/omi/components/docs/cn.html#/icon
2020-04-24 18:43:58 +08:00
[omiu-icon-codepen]: https://tencent.github.io/omi/components/icon/demos/icon.html
[omiu-tabs-github]: https://github.com/Tencent/omi/tree/master/components/tabs
[omiu-tabs-status]: https://img.shields.io/npm/v/@omiu/tabs.svg
[omiu-tabs-package]: https://www.npmjs.com/package/@omiu/tabs
2020-04-26 21:18:25 +08:00
[omiu-tabs-docs]: https://tencent.github.io/omi/components/docs/cn.html#/tabs
2020-04-24 18:43:58 +08:00
[omiu-tabs-codepen]: https://codepen.io/omijs/pen/XWmjyXK
[omiu-radio-github]: https://github.com/Tencent/omi/tree/master/components/radio
[omiu-radio-status]: https://img.shields.io/npm/v/@omiu/radio.svg
[omiu-radio-package]: https://www.npmjs.com/package/@omiu/radio
2020-04-26 21:18:25 +08:00
[omiu-radio-docs]: https://tencent.github.io/omi/components/docs/cn.html#/radio
2020-04-24 18:43:58 +08:00
[omiu-radio-codepen]: https://codepen.io/omijs/pen/GRpjapr
[omiu-link-github]: https://github.com/Tencent/omi/tree/master/components/link
[omiu-link-status]: https://img.shields.io/npm/v/@omiu/link.svg
[omiu-link-package]: https://www.npmjs.com/package/@omiu/link
2020-04-26 21:18:25 +08:00
[omiu-link-docs]: https://tencent.github.io/omi/components/docs/cn.html#/link
2020-04-24 18:43:58 +08:00
[omiu-link-codepen]: https://codepen.io/omijs/pen/KKdNBaO
2020-04-26 17:43:01 +08:00
2020-04-24 18:43:58 +08:00
[omiu-hamburger-menu-github]: https://github.com/Tencent/omi/tree/master/components/hamburger-menu
[omiu-hamburger-menu-status]: https://img.shields.io/npm/v/@omiu/hamburger-menu.svg
[omiu-hamburger-menu-package]: https://www.npmjs.com/package/@omiu/hamburger-menu
2020-04-26 21:18:25 +08:00
[omiu-hamburger-menu-docs]: https://tencent.github.io/omi/components/docs/cn.html#/hamburger-menu
2020-04-24 18:43:58 +08:00
[omiu-hamburger-menu-codepen]: https://codepen.io/omijs/pen/MWapaJd
2020-04-25 17:47:35 +08:00
[omiu-input-github]: https://github.com/Tencent/omi/tree/master/components/input
[omiu-input-status]: https://img.shields.io/npm/v/@omiu/input.svg
[omiu-input-package]: https://www.npmjs.com/package/@omiu/input
2020-04-26 21:18:25 +08:00
[omiu-input-docs]: https://tencent.github.io/omi/components/docs/cn.html#/input
2020-04-25 17:47:35 +08:00
[omiu-input-codepen]: https://codepen.io/omijs/pen/yLYMGqa
2020-04-26 17:43:01 +08:00
[omiu-checkbox-github]: https://github.com/Tencent/omi/tree/master/components/checkbox
[omiu-checkbox-status]: https://img.shields.io/npm/v/@omiu/checkbox.svg
[omiu-checkbox-package]: https://www.npmjs.com/package/@omiu/checkbox
2020-04-26 21:18:25 +08:00
[omiu-checkbox-docs]: https://tencent.github.io/omi/components/docs/cn.html#/checkbox
2020-04-26 17:43:01 +08:00
[omiu-checkbox-codepen]: https://codepen.io/omijs/pen/MWapwNZ
[omiu-switch-github]: https://github.com/Tencent/omi/tree/master/components/switch
[omiu-switch-status]: https://img.shields.io/npm/v/@omiu/switch.svg
[omiu-switch-package]: https://www.npmjs.com/package/@omiu/switch
2020-04-26 21:18:25 +08:00
[omiu-switch-docs]: https://tencent.github.io/omi/components/docs/index.html#/switch
2020-04-26 17:43:01 +08:00
[omiu-switch-codepen]: https://codepen.io/omijs/pen/BaoRpLd
2020-04-25 21:03:59 +08:00
[omiu-tree-github]: https://github.com/Tencent/omi/tree/master/components/tree
[omiu-tree-status]: https://img.shields.io/npm/v/@omiu/tree.svg
[omiu-tree-package]: https://www.npmjs.com/package/@omiu/tree
2020-04-26 21:18:25 +08:00
[omiu-tree-docs]: https://tencent.github.io/omi/components/docs/cn.html#/tree
2020-04-25 21:03:59 +08:00
[omiu-tree-codepen]: https://codepen.io/omijs/pen/yLYMrdg
2020-04-26 11:17:20 +08:00
[omiu-pagination-github]: https://github.com/Tencent/omi/tree/master/components/pagination
[omiu-pagination-status]: https://img.shields.io/npm/v/@omiu/pagination.svg
[omiu-pagination-package]: https://www.npmjs.com/package/@omiu/pagination
2020-04-26 21:18:25 +08:00
[omiu-pagination-docs]: https://tencent.github.io/omi/components/docs/cn.html#/pagination
2020-04-26 11:17:20 +08:00
[omiu-pagination-codepen]: https://codepen.io/omijs/pen/MWamyBQ
2020-04-25 21:40:39 +08:00
[omiu-loading-github]: https://github.com/Tencent/omi/tree/master/components/loading
[omiu-loading-status]: https://img.shields.io/npm/v/@omiu/loading.svg
[omiu-loading-package]: https://www.npmjs.com/package/@omiu/loading
2020-04-26 21:18:25 +08:00
[omiu-loading-docs]: https://tencent.github.io/omi/components/docs/cn.html#/loading
2020-04-25 21:40:39 +08:00
[omiu-loading-codepen]: https://codepen.io/omijs/pen/oNjZRwO
2020-04-26 09:19:32 +08:00
[omiu-toast-github]: https://github.com/Tencent/omi/tree/master/components/toast
[omiu-toast-status]: https://img.shields.io/npm/v/@omiu/toast.svg
[omiu-toast-package]: https://www.npmjs.com/package/@omiu/toast
2020-04-26 21:18:25 +08:00
[omiu-toast-docs]: https://tencent.github.io/omi/components/docs/cn.html#/toast
2020-04-26 09:19:32 +08:00
[omiu-toast-codepen]: https://codepen.io/omijs/pen/YzyVwOO
2020-04-26 17:11:25 +08:00
[omiu-action-sheet-github]: https://github.com/Tencent/omi/tree/master/components/action-sheet
[omiu-action-sheet-status]: https://img.shields.io/npm/v/@omiu/action-sheet.svg
[omiu-action-sheet-package]: https://www.npmjs.com/package/@omiu/action-sheet
2020-04-26 21:18:25 +08:00
[omiu-action-sheet-docs]: https://tencent.github.io/omi/components/docs/cn.html#/action-sheet
2020-04-26 17:11:25 +08:00
[omiu-action-sheet-codepen]: https://codepen.io/omijs/pen/wvKdoNJ
2020-04-26 17:43:01 +08:00
2020-04-26 20:15:59 +08:00
[omiu-color-picker-github]: https://github.com/Tencent/omi/tree/master/components/color-picker
[omiu-color-picker-status]: https://img.shields.io/npm/v/@omiu/color-picker.svg
[omiu-color-picker-package]: https://www.npmjs.com/package/@omiu/color-picker
2020-04-26 21:18:25 +08:00
[omiu-color-picker-docs]: https://tencent.github.io/omi/components/docs/cn.html#/color-picker
2020-04-26 20:15:59 +08:00
[omiu-color-picker-codepen]: https://codepen.io/omijs/pen/gOaWmZE
2020-04-27 09:16:40 +08:00
[omiu-chart-github]: https://github.com/Tencent/omi/tree/master/components/chart
[omiu-chart-status]: https://img.shields.io/npm/v/@omiu/chart.svg
[omiu-chart-package]: https://www.npmjs.com/package/@omiu/chart
[omiu-chart-docs]: https://tencent.github.io/omi/components/docs/cn.html#/chart
[omiu-chart-codepen]: https://codepen.io/omijs/pen/pojPKLr
2020-04-27 17:54:41 +08:00
[omiu-toggle-icon-github]: https://github.com/Tencent/omi/tree/master/components/toggle-icon
[omiu-toggle-icon-status]: https://img.shields.io/npm/v/@omiu/toggle-icon.svg
[omiu-toggle-icon-package]: https://www.npmjs.com/package/@omiu/toggle-icon
[omiu-toggle-icon-docs]: https://tencent.github.io/omi/components/docs/cn.html#/toggle-icon
[omiu-toggle-icon-codepen]: https://codepen.io/omijs/pen/ZEbKwXX
2020-04-28 19:46:50 +08:00
[omiu-o-icon-github]: https://github.com/Tencent/omi/tree/master/components/o-icon
[omiu-o-icon-status]: https://img.shields.io/npm/v/@omiu/o-icon.svg
[omiu-o-icon-package]: https://www.npmjs.com/package/@omiu/o-icon
[omiu-o-icon-docs]: https://tencent.github.io/omi/components/docs/cn.html#/o-icon
[omiu-o-icon-codepen]: https://codepen.io/omijs/pen/QWjgapY
[omiu-badge-github]: https://github.com/Tencent/omi/tree/master/components/badge
[omiu-badge-status]: https://img.shields.io/npm/v/@omiu/badge.svg
[omiu-badge-package]: https://www.npmjs.com/package/@omiu/badge
[omiu-badge-docs]: https://tencent.github.io/omi/components/docs/cn.html#/badge
[omiu-badge-codepen]: https://codepen.io/omijs/pen/WNQOdaB
[omiu-avatar-github]: https://github.com/Tencent/omi/tree/master/components/avatar
[omiu-avatar-status]: https://img.shields.io/npm/v/@omiu/avatar.svg
[omiu-avatar-package]: https://www.npmjs.com/package/@omiu/avatar
[omiu-avatar-docs]: https://tencent.github.io/omi/components/docs/cn.html#/avatar
[omiu-avatar-codepen]: https://codepen.io/omijs/pen/QWjgaze
2020-04-29 19:28:55 +08:00
[omiu-breadcrumb-github]: https://github.com/Tencent/omi/tree/master/components/breadcrumb
[omiu-breadcrumb-status]: https://img.shields.io/npm/v/@omiu/breadcrumb.svg
[omiu-breadcrumb-package]: https://www.npmjs.com/package/@omiu/breadcrumb
2020-04-29 19:30:19 +08:00
[omiu-breadcrumb-docs]: https://tencent.github.io/omi/components/docs/cn.html#/breadcrumb
2020-04-29 19:28:55 +08:00
[omiu-breadcrumb-codepen]: https://codepen.io/omijs/pen/wvKqGxB
2020-04-30 09:25:53 +08:00
[omiu-bottom-nav-github]: https://github.com/Tencent/omi/tree/master/components/bottom-nav
[omiu-bottom-nav-status]: https://img.shields.io/npm/v/@omiu/bottom-nav.svg
[omiu-bottom-nav-package]: https://www.npmjs.com/package/@omiu/bottom-nav
[omiu-bottom-nav-docs]: https://tencent.github.io/omi/components/docs/cn.html#/bottom-nav
[omiu-bottom-nav-codepen]: https://codepen.io/omijs/pen/zYvdjEY
2020-05-01 20:37:35 +08:00
[omiu-transition-github]: https://github.com/Tencent/omi/tree/master/components/transition
[omiu-transition-status]: https://img.shields.io/npm/v/@omiu/transition.svg
[omiu-transition-package]: https://www.npmjs.com/package/@omiu/transition
[omiu-transition-docs]: https://tencent.github.io/omi/components/docs/cn.html#/transition
[omiu-transition-codepen]: https://codepen.io/omijs/pen/JjYyezQ
2020-05-03 18:45:41 +08:00
[omiu-dialog-github]: https://github.com/Tencent/omi/tree/master/components/dialog
[omiu-dialog-status]: https://img.shields.io/npm/v/@omiu/dialog.svg
[omiu-dialog-package]: https://www.npmjs.com/package/@omiu/dialog
[omiu-dialog-docs]: https://tencent.github.io/omi/components/docs/cn.html#/dialog
[omiu-dialog-codepen]: https://codepen.io/omijs/pen/JjYyezQ
2020-05-04 16:37:36 +08:00
[omiu-dialog-extention-github]: https://github.com/Tencent/omi/tree/master/components/dialog-extention
[omiu-dialog-extention-status]: https://img.shields.io/npm/v/@omiu/dialog-extention.svg
[omiu-dialog-extention-package]: https://www.npmjs.com/package/@omiu/dialog-extention
[omiu-dialog-extention-docs]: https://tencent.github.io/omi/components/docs/cn.html#/dialog-extention
[omiu-dialog-extention-codepen]: https://codepen.io/omijs/pen/GRpOBmL
2019-08-29 09:45:52 +08:00
## 快速概览
整个组件树共享数据,并且数据变更自动更新视图。
```jsx
import { define, render } from 'omi'
class Store {
data = {
count: 1
}
sub = () => {
this.data.count--
}
add = () => {
this.data.count++
}
}
2019-09-26 15:57:56 +08:00
define('my-counter', _ => (
2019-08-29 09:45:52 +08:00
<div>
<button onClick={_.store.sub}>-</button>
<span>{_.store.data.count}</span>
<button onClick={_.store.add}>+</button>
</div>
2019-08-29 11:18:26 +08:00
), {
2019-09-26 15:57:56 +08:00
use: ['count'],
//或者使用 useSelf, useSelf 只会更新自身,不更新子组件
//useSelf: ['count'],
2019-08-29 11:18:26 +08:00
css: `span { color: red; }`,
installed() {
console.log('installed')
}
})
2019-08-29 09:45:52 +08:00
render(<my-counter />, 'body', new Store)
```
2019-09-01 15:52:50 +08:00
* `<my-counter></my-counter>` 可以用于任意框架或者无框架,比如 `document.createElement('my-counter')`
2019-10-29 13:30:31 +08:00
你也可以使用 `useSelf`, `useSelf` 只会更新自身,不更新子组件。使用 `useSelf` 的时候在 JSX 里通过 `usingSelf` 访问对应属性。
你也可以通过 `compute` 去实现 `computed` 计算属性,比如:
2019-09-30 12:29:38 +08:00
```jsx
define('my-counter', _ => (
<div>
<button onClick={_.store.sub}>-</button>
<span>{_.store.data.count}</span>
<button onClick={_.store.add}>+</button>
2019-10-29 13:30:31 +08:00
<div>Double: {_.computed.doubleCount}</div>
2019-09-30 12:29:38 +08:00
</div>
), {
2019-10-29 13:30:31 +08:00
use: ['count'],
compute: {
doubleCount() {
return this.count * 2
}
}
2019-09-30 12:29:38 +08:00
})
```
2019-10-02 19:35:33 +08:00
路径也是支持的,比如下面的例子:
```js
class Store {
data = {
list: [
{ name: { first: 'dnt', last: 'zhang' } }
]
}
}
...
...
define('my-counter', _ => (
...
...
), {
use: [
'list[0].name', //可以通过 this.using[0] 访问
2019-10-29 13:30:31 +08:00
],
compute: {
fullName() {
return this.list[0].name.first + this.list[0].name.last
}
}
2019-10-02 19:35:33 +08:00
})
```
2019-11-01 13:27:12 +08:00
![](https://tencent.github.io/omi/assets/store.cn.jpg)
2019-10-03 17:22:21 +08:00
### 多个 store 注入
```jsx
import { define, render } from 'omi'
define('my-app', _ => {
2019-10-08 10:42:24 +08:00
const store = _.store.storeA
const { data, add, sub } = store
return (
<p>
Clicked: {data.count} times
<button onClick={add}>+</button>
<button onClick={sub}>-</button>
<div>
{_.store.storeB.data.msg}
<button onClick={_.store.storeB.changeMsg}>
change storeB's msg
</button>
</div>
</p>
)
}, {
2019-10-08 10:42:24 +08:00
useSelf: {
storeA: ['count', 'adding'],
storeB: ['msg']
}
})
const storeA = new class Store {
2019-10-08 10:42:24 +08:00
data = {
count: 0,
adding: false
}
sub = () => {
this.data.count--
}
add = () => {
this.data.count++
}
}
const storeB = new class Store {
2019-10-08 10:42:24 +08:00
data = {
msg: 'abc'
}
changeMsg = () => {
this.data.msg = 'bcd'
}
}
render( <my-app /> , 'body', {
2019-10-08 10:42:24 +08:00
storeA,
storeB
})
```
怎么在注入多 store 的时候使用 `compute` and `computed`? 非常简单:
```jsx
define('my-app', _ => {
2019-10-29 13:54:09 +08:00
const store = _.store.storeA
const { data, add, sub } = store
return (
<p>
Clicked: {data.count} times
2019-10-29 13:56:54 +08:00
<button onClick={add}>+</button>
2019-10-29 13:54:09 +08:00
<button onClick={sub}>-</button>
2019-10-29 13:54:09 +08:00
<div>
{_.store.storeB.data.msg}
<button onClick={_.store.storeB.changeMsg}>
change storeB's msg
2019-10-29 13:56:54 +08:00
</button>
2019-10-29 13:54:09 +08:00
</div>
2019-10-29 13:54:09 +08:00
<div>{_.computed.dobuleCount}</div>
<div>{_.computed.reverseMsg}</div>
</p>
)
}, {
2019-10-29 13:54:09 +08:00
useSelf: {
storeA: ['count', 'adding'],
storeB: ['msg']
},
compute: {
dobuleCount() {
return this.storeA.data.count * 2
},
reverseMsg() {
return this.storeB.data.msg.split('').reverse().join('')
}
}
})
```
2019-10-04 09:37:24 +08:00
### API 和 钩子
```jsx
define('my-component', _ => (
...
...
), {
use: ['path', 'path.a', 'path[1].b'],
useSelf: ['path.c', 'path[1].d'],
css: 'h1 { color: red; }',
2020-05-01 06:38:48 +08:00
propTypes: { },
defaultProps: { },
2020-05-01 06:34:46 +08:00
isLightDom: true, //default is false
2019-10-04 09:37:24 +08:00
//生命周期
install() { },
installed() { },
uninstall() { },
receiveProps() { },
beforeUpdate() { },
updated() { },
beforeRender() { },
2019-10-28 14:37:14 +08:00
rendered() { },
//自定义方法
myMethodA() { },
myMethodB() { }
2019-10-04 09:37:24 +08:00
})
```
2019-12-27 12:09:14 +08:00
### 通过 prop 注入 use 或 useSelf
```jsx
<my-counter use={['count']} ></my-counter>
```
2018-11-05 14:47:11 +08:00
## Omi 生态
2018-12-24 10:16:10 +08:00
[→ Omi 生态学习路线图](https://github.com/Tencent/omi/tree/master/assets/rm.md)
2018-12-24 10:06:38 +08:00
2019-04-05 15:51:49 +08:00
#### 基础生态
2018-11-05 14:47:11 +08:00
| **项目** | **描述** |
| ------------------------------- | ----------------------------------- |
2019-10-02 08:14:54 +08:00
| [omi-docs](https://tencent.github.io/omi/site/docs/cn.html) 和 [例子](https://codepen.io/collection/DrMYgV/) 和 [webcomponents.dev](https://webcomponents.dev/)| Omi 官方文档 |
2019-11-04 12:31:44 +08:00
| [omix![](https://dntzhang.github.io/cax/asset/hot.png)](https://github.com/Tencent/omi/tree/master/packages/omix)| 小程序全局状态管理框架,数据触手可及,状态无处遁形 |
| [omim![](https://dntzhang.github.io/cax/asset/hot.png)](https://github.com/Tencent/omi/tree/master/packages/omim)| Omi 打造的跨框架 Material Design UI 组件库, 任意框架可以使用,([DOCS & REPL](https://tencent.github.io/omi/packages/omim/docs/build/cn.html) && [加入我们](https://github.com/Tencent/omi/tree/master/packages/omim#contribution)!)|
| [omi-kbone![](https://dntzhang.github.io/cax/asset/hot.png) ](https://github.com/Tencent/omi/tree/master/packages/omi-kbone)| 使用 omi + [kbone](https://github.com/wechat-miniprogram/kbone) 多端开发(小程序和Web)的贪吃蛇游戏。|
2019-08-18 22:02:49 +08:00
| [omio](https://github.com/Tencent/omi/tree/master/packages/omio)| 兼容老浏览器的 Omi 版本(支持到 IE8+) |
2019-11-04 12:31:44 +08:00
| [omis![](https://dntzhang.github.io/cax/asset/hot.png) ](https://github.com/Tencent/omi/tree/master/packages/omis)| Omis + React|
2019-07-20 13:18:04 +08:00
| [omi-ssr](https://github.com/Tencent/omi/tree/master/packages/omi-ssr)| 服务端同构渲染解决方案(目前只能用 omio) |
2019-06-05 10:36:25 +08:00
| [omiu](https://tencent.github.io/omi/packages/omiu/examples/build/zh-cn.html)| 简单 Omi UI|
2019-04-28 14:35:22 +08:00
| [omi-router ](https://github.com/Tencent/omi/tree/master/packages/omi-router) |Omi 官方路由,超级小的尺寸,只有 1KB 的 js|
2019-04-05 15:51:49 +08:00
| [omi-devtools](https://github.com/f/omi-devtools)| 谷歌浏览器开发工具扩展|
2019-04-30 14:42:18 +08:00
| [omi-cli](https://github.com/Tencent/omi/tree/master/packages/omi-cli)| 项目脚手架工具,各种模板任你选 [→ 基础模板](https://github.com/Tencent/omi/tree/master/packages/omi-cli/template) and [→ 其他模板](https://github.com/omijs) |
2019-08-19 09:55:09 +08:00
| [omil](https://github.com/Wscats/omil)| 基于 .omi 单文件组件的 webpack 模块加载器 |
2019-08-18 22:02:49 +08:00
| [omi-snippets](https://github.com/Wscats/omi-snippets) | VSCode omi 文件扩展, [立即安装!](https://marketplace.visualstudio.com/items?itemName=Wscats.omi-snippets) |
2019-08-26 12:05:44 +08:00
| [obaa](https://github.com/Tencent/omi/tree/master/packages/obaa) 或 [JSONPatcherProxy](https://github.com/Palindrom/JSONPatcherProxy) | 监听或代理任意对象的任意变化 |
2021-05-17 13:37:04 +08:00
<!-- | [omiv![](https://dntzhang.github.io/cax/asset/hot.png) ](https://github.com/Tencent/omi/tree/master/packages/omiv)| 1kb 搞定 Vue 无状态视图状态管理,[也可以 SSR](https://github.com/Tencent/omi/tree/master/packages/vue-omiv-ssr-starter) | -->
2019-08-22 10:56:19 +08:00
#### Snake MVP
| **Project** | **Description** |
| ------------------------------- | ----------------------------------- |
2019-11-04 12:31:44 +08:00
| [omi-snake![](https://dntzhang.github.io/cax/asset/hot.png) ](https://github.com/Tencent/omi/tree/master/packages/omi-snake)| omi 写的 MVP 架构的贪吃蛇游戏 |
2019-11-09 09:36:56 +08:00
| [omi-kbone-snake![](https://dntzhang.github.io/cax/asset/hot.png) ](https://github.com/Tencent/omi/tree/master/packages/omi-kbone)| omi-kbone 写的 MVP 架构的跨端贪吃蛇游戏,支持小程序和 H5 |
2019-11-04 12:33:36 +08:00
| [Preact-snake](https://github.com/Tencent/omi/tree/master/packages/preact-css/examples/snake) & [→ Touch the demo](https://tencent.github.io/omi/packages/preact-css/examples/snake/build/)| Preact + [Preact-CSS](https://github.com/Tencent/omi/tree/master/packages/preact-css) + Omis 写的贪吃蛇 |
| [[P]react-snake ](https://github.com/Tencent/omi/tree/master/packages/react-snake) & [→ Touch the demo](https://tencent.github.io/omi/packages/react-snake/build/index.html)| react/preact 写的 MVP 架构的贪吃蛇游戏 |
2019-11-04 12:31:44 +08:00
| [omix-snake![](https://dntzhang.github.io/cax/asset/hot.png)](https://github.com/Tencent/omi/tree/master/packages/omix-snake) | Omix 写的 MVP 架构贪吃蛇 |
2021-05-17 13:37:04 +08:00
<!-- | [vue-snake](https://github.com/Tencent/omi/tree/master/packages/vue-snake) | Vue + Omiv 写的 MVP 架构的贪吃蛇游戏 | -->
2019-08-22 10:56:19 +08:00
2019-04-05 15:51:49 +08:00
#### 小程序生态
| **项目** | **描述** |
| ------------------------------- | ----------------------------------- |
2019-11-04 12:31:44 +08:00
| [omix![](https://dntzhang.github.io/cax/asset/hot.png)](https://github.com/Tencent/omi/tree/master/packages/omix)| 小程序全局状态管理框架,数据触手可及,状态无处遁形 |
| [react-kbone![](https://dntzhang.github.io/cax/asset/hot.png) ](https://github.com/Tencent/omi/tree/master/packages/react-kbone)| 直接使用 React 开发小程序或 Web基于 [kbone](https://github.com/wechat-miniprogram/kbone) |
| [preact-kbone![](https://dntzhang.github.io/cax/asset/hot.png) ](https://github.com/Tencent/omi/tree/master/packages/preact-kbone)| 直接使用 Preact 开发小程序或 Web基于 [kbone](https://github.com/wechat-miniprogram/kbone) |
2019-07-19 15:52:51 +08:00
| [omi-cloud](https://github.com/Tencent/omi/tree/master/packages/omi-cloud)| 小程序•云开发|
2019-08-08 12:07:01 +08:00
| [omip](https://github.com/Tencent/omi/tree/master/packages/omip)| 直接使用 Omi 开发小程序或 H5 SPA|
2019-08-20 09:03:37 +08:00
| [mps](https://github.com/Tencent/omi/tree/master/packages/mps)| 原生小程序增强框架(JSX + Less 输出 WXML + WXSS),也支持 QQ 轻应用 |
2019-08-08 12:07:01 +08:00
| [cax](https://github.com/Tencent/omi/tree/master/packages/cax)| 小程序 Canvas 和 SVG 渲染引擎 |
2019-08-18 22:02:49 +08:00
| [omi-mp](https://github.com/Tencent/omi/tree/master/packages/omi-mp)| 通过微信小程序开发和生成 Web 单页应用(H5 SPA) |
2019-07-22 12:45:57 +08:00
| [westore](https://github.com/Tencent/westore/)| 小程序状态管理 |
2019-04-05 15:51:49 +08:00
| [comi](https://github.com/Tencent/omi/tree/master/packages/comi)| 小程序代码高亮和 markdown 渲染组件 |
2019-04-05 17:00:22 +08:00
| [wx-touch-event](https://github.com/qbright/wx-touch-event)| 基于 AlloyFinger/omi-finger 改造的小程序手势解决方案 |
2019-04-05 15:51:49 +08:00
#### 其他
| **项目** | **描述** |
| ------------------------------- | ----------------------------------- |
2019-11-04 12:31:44 +08:00
| [omi-piano![](https://dntzhang.github.io/cax/asset/hot.png)](https://github.com/Wscats/piano) |Omi 钢琴, [开始演奏吧!](https://wscats.github.io/piano/build/)|
2019-02-27 15:45:44 +08:00
| [md2site](https://tencent.github.io/omi/assets/md2site/)| 用 markdown 生成静态网站文档.|
2018-12-19 11:25:40 +08:00
| [omi-chart](https://github.com/Tencent/omi/tree/master/packages/omi-chart)| 一个 chart-x 标签搞定报表|
| [omi-30-seconds](https://github.com/Tencent/omi/tree/master/packages/omi-30-seconds)| 30 秒理解一段有用的 Omi 代码片段.|
2019-02-26 20:19:16 +08:00
| [omi-swiper](https://github.com/loo41/Omi-Swiper)| Omi + Swiper |
2019-08-18 22:02:49 +08:00
| [omi-vscode](https://github.com/ZainChen/omi-vscode)| VSCode extension for omi, [Install now!](https://marketplace.visualstudio.com/items?itemName=ZainChen.omi) |
2018-12-11 14:06:36 +08:00
| [omi-sprite](https://github.com/Tencent/omi/tree/master/packages/omi-sprite)| Web Components, JSX 和 Canvas 的完美融合|
2018-11-26 13:09:56 +08:00
| [omi-canvas](https://github.com/Tencent/omi/tree/master/packages/omi-canvas)| Web Components, JSX 和 Canvas 的完美融合|
2018-12-09 15:46:37 +08:00
| [omi-ex](https://github.com/Tencent/omi/tree/master/packages/omi-ex)| Omi.js 扩展(TypeScript) |
2019-08-19 09:50:12 +08:00
| [omi-transform](https://github.com/Tencent/omi/tree/master/packages/omi-transform)|Omi 和 [css3transform](https://tencent.github.io/omi/packages/omi-transform/css3transform/) 完美结合. 让 css3 transform 在你的 Omi 项目中变得超级简单.|
2018-11-05 14:47:11 +08:00
| [omi-finger](https://github.com/Tencent/omi/tree/master/packages/omi-finger)|Omi 官方手势库|
| [omi-touch](https://github.com/Tencent/omi/tree/master/packages/omi-touch)|丝般顺滑的触摸运动|
2019-03-04 10:21:59 +08:00
| [omi-snap](https://github.com/Tencent/omi/blob/master/tutorial/omi-snap.cn.md)|预渲染骨架屏|
2018-11-10 14:05:26 +08:00
|[omi-i18n](https://github.com/i18next/omi-i18n)| Omi 国际化解决方案 |
| [omi-page](https://github.com/Tencent/omi/tree/master/packages/omi-page) | 基于 [page.js](https://github.com/visionmedia/page.js) 的 Omi 路由|
2019-08-18 22:02:49 +08:00
| [omie](https://github.com/Wscats/omi-electron) | Omi.js 和 Electron.js 打造跨平台桌面应用 |
2019-10-24 09:07:06 +08:00
| [Soo](https://github.com/tonis2/Soo)| 和 Omi 一样的 API但是更小且没有 JSX, virtual DOM 和 store|
2019-11-01 19:37:04 +08:00
| [CEE](https://omijs.github.io/cee/out/)| custom-elements-everywhere 评分 |
2018-10-15 09:45:24 +08:00
2019-02-26 15:49:06 +08:00
### 特性
2019-05-07 11:33:24 +08:00
- 框架无关,任何框架可以使用 Omi 自定义元素
2019-03-25 16:56:40 +08:00
- 提供桌面、移动和小程序整体解决方案
2019-09-26 16:00:17 +08:00
- 无状态视图的架构设计
2019-07-28 10:33:43 +08:00
- 小巧的尺寸和[高性能](https://tencent.github.io/omi/packages/omi/examples/perfs/)
2019-07-28 10:35:22 +08:00
- 对 custom elements 友好, 通过字符串 `'0'`或者`'false'`传递 `false`[通过`:`和`Omi.$`传递任意复杂类型](https://github.com/Tencent/omi/releases/tag/v6.8.0)
2019-05-19 20:01:26 +08:00
- 拥有官方跨框架 UI 组件库 - [omim](https://tencent.github.io/omi/packages/omim/docs/build/cn.html)
2019-02-26 15:49:06 +08:00
- 使用 [omio](https://github.com/Tencent/omi/tree/master/packages/omio) 可以兼容到 IE8
2019-08-21 11:46:58 +08:00
- [很容易通过 extend api 实现双向绑定](https://codepen.io/omijs/pen/aeLYjx)
2019-02-26 15:49:06 +08:00
- 支持 `TypeScript`
- 响应式数据绑定
- 增强了 CSS, [支持 rpx 单位](https://github.com/Tencent/omi/releases/tag/v4.0.26),基于 **750** 屏幕宽度
2019-07-15 14:47:36 +08:00
- [原生支持 tap 事件](https://github.com/Tencent/omi/releases/tag/v4.0.24)
2020-05-01 20:45:00 +08:00
- [基于 Shadow/Light Dom 设计](https://developers.google.cn/web/fundamentals/web-components/shadowdom?hl=zh-cn)
2019-08-18 22:02:49 +08:00
- 利用 [Chrome 开发工具扩展 ](https://github.com/f/omi-devtools)轻松调试,[从 Chrome 应用商店安装](https://chrome.google.com/webstore/detail/omijs-devtools/pjgglfliglbhpcpalbpeloghnbceocmd/related)
- 符合浏览器的发展趋势以及 API 设计理念
2019-11-07 10:58:06 +08:00
- [**Web Components**](https://developers.google.com/web/fundamentals/web-components/) + [**JSX**](https://reactjs.org/docs/introducing-jsx.html) 融合为一个框架 Omi
2019-02-26 15:49:06 +08:00
- Web Components 也可以数据驱动视图, `UI = fn(data)`
- JSX 是开发体验最棒(智能提示)、[语法噪音最少](https://github.com/facebook/jsx#why-not-template-literals)、图灵完备的 UI 表达式,模板引擎不完备,模板字符串完备但是语法噪音太大
2019-08-18 22:02:49 +08:00
- 看看 [Facebook React 和 Web Components 对比优势](https://www.cnblogs.com/rubylouvre/p/4072979.html)Omi 融合了各自的优点,而且给开发者自由的选择喜爱的方式
2020-05-01 20:45:00 +08:00
- `Shadow/Light DOM``Virtual DOM` 融合Omi 既使用了`虚拟 DOM`,也是使用真实 `Shadow DOM`,让视图更新更准确更迅速
2019-08-18 22:02:49 +08:00
- 局部 CSS 最佳解决方案(`Shadow DOM`),社区为局部 CSS 折腾了不少框架和库(使用 js 或 json 写样式,如:`Radium``jsxstyle``react-style`;与 webpack 绑定使用生成独特的 className `文件名—类名—hash值`,如:`CSS Modules``Vue`),还有运行时注入`scoped atrr` 的方式,都是 hack 技术;`Shadow DOM Style` 是最完美的方案
2019-03-25 16:56:40 +08:00
- 独创的 `Path Updating``store` 系统,基于 Proxy 全自动化的精准更新,功耗低,自由度高,性能卓越,方便集成 `requestIdleCallback`,自动化按需更新局部视图
2019-02-26 15:49:06 +08:00
2020-05-01 20:45:00 +08:00
对比同样开发 TodoApp Omi 和 React 渲染完的 DOM 结构Omi 使用 Shadow/Light DOM 隔离样式和语义化结构:
2019-02-26 15:49:06 +08:00
2019-09-23 17:16:31 +08:00
| **Omi** | **React** | **Omio** |
| ------------------------------- | ----------------------------------- |----------------------------------- |
2019-09-23 17:24:15 +08:00
| ![Omi](https://tencent.github.io/omi/assets/omi-render.jpg) | ![React](https://tencent.github.io/omi/assets/react-render.jpg) | ![Omio](https://tencent.github.io/omi/assets/omio.png) |
2019-02-26 15:49:06 +08:00
2019-04-22 17:52:08 +08:00
### TypeScript 智能提示
```jsx
import { h, WeElement, tag, classNames } from 'omi';
2019-04-23 09:34:26 +08:00
import * as styles from './_index.less';
interface ButtonProps {
href?: string,
disabled?: boolean,
type?: 'default' | 'primary' | 'danger',
htmltype?: 'submit' | 'button' | 'reset',
onClick?: (e: any) => void
}
const TAG = 'o-button'
2019-04-22 17:52:08 +08:00
declare global {
namespace JSX {
interface IntrinsicElements {
2019-04-30 10:09:41 +08:00
[TAG]: Omi.Props & ButtonProps
2019-04-22 17:52:08 +08:00
}
}
}
2019-04-23 09:34:26 +08:00
@tag(TAG)
2019-09-25 10:56:48 +08:00
export default class oButton extends WeElement<ButtonProps> {
2019-04-23 09:34:26 +08:00
...
2019-04-22 17:52:08 +08:00
...
...
```
2019-04-23 09:40:15 +08:00
<img src="./assets/ts.png" alt="omi" width="427"/>
2019-04-22 17:52:08 +08:00
2018-11-06 08:39:32 +08:00
## 必须收藏的资源
2019-09-02 10:29:32 +08:00
* [使用 MVP 架构和 Web Components(Omi) 开发贪吃蛇](https://github.com/Tencent/omi/blob/master/tutorial/omi-web-components-snake-game-mvp.cn.md)
2019-08-14 10:55:16 +08:00
* [Web Components 规范](https://github.com/w3c/webcomponents)
2019-04-09 11:26:52 +08:00
* [Comi 原理揭秘](https://github.com/Tencent/omi/blob/master/tutorial/comi-principle.md)
2019-03-25 16:56:40 +08:00
* [Omip 编译 H5 原理揭秘](https://github.com/Tencent/omi/blob/master/tutorial/omip-h5.md)
2019-04-10 11:41:15 +08:00
* [如何通过小程序实现跨平台开发](https://developers.weixin.qq.com/community/develop/article/doc/00002cda45c930d87a380a74351813)
2019-01-08 10:41:39 +08:00
* [你必须收藏 ES6 Spread Operator 技巧](https://github.com/Tencent/omi/blob/master/tutorial/spread-operator.cn.md)
2019-03-25 16:56:40 +08:00
* [Omi snap 骨架屏与快照](https://github.com/Tencent/omi/blob/master/tutorial/omi-snap.cn.md)
2018-12-24 14:58:36 +08:00
* [Omio 兼容 IE8 踩坑之路](https://github.com/Tencent/omi/blob/master/tutorial/omio.cn.md)
2019-03-25 16:56:40 +08:00
* [Omi 生态发布](https://github.com/Tencent/omi/blob/master/tutorial/ecosystem.cn.md)
2018-11-30 13:10:11 +08:00
* [深入浅出 Shadow Dom](https://github.com/Tencent/omi/blob/master/tutorial/shadow-dom-in-depth.cn.md)
2018-11-22 10:27:01 +08:00
* [HTM - JSX 的替代品?还是另一种选择?](https://github.com/Tencent/omi/blob/master/tutorial/omi-html.cn.md)
2019-03-25 16:56:40 +08:00
* [MVVM 王者归来](https://github.com/Tencent/omi/blob/master/tutorial/omi-mvvm.cn.md)
2018-11-13 16:21:22 +08:00
* [60FPS Animation In Omi](https://github.com/Tencent/omi/blob/master/tutorial/omi-transform.cn.md)
2018-11-07 09:40:39 +08:00
* [Render Web Components To Native](https://github.com/Tencent/omi/blob/master/tutorial/render-web-components-to-native.cn.md)
2018-11-06 08:39:32 +08:00
* [Web Components MDN](https://developer.mozilla.org/zh-CN/docs/Web/Web_Components)
* [Web Components Google](https://developers.google.com/web/fundamentals/web-components/)
* [Web Components Org](https://www.webcomponents.org/introduction)
* [Proxy MDN](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
* [CSS Variables](https://developer.mozilla.org/zh-CN/docs/Web/CSS/Using_CSS_variables)
* [CSS Shadow Parts](https://drafts.csswg.org/css-shadow-parts-1/)
* [Part Theme Explainer](https://meowni.ca/posts/part-theme-explainer/)
2018-11-14 10:29:07 +08:00
* [Platform HTML5](https://platform.html5.org/)
2018-11-28 17:59:50 +08:00
* [使用 requestIdleCallback](https://div.io/topic/1370)
* [A requestIdleCallback polyfill](https://gist.github.com/paullewis/55efe5d6f05434a96c36)
2019-03-25 16:56:40 +08:00
* [Web Components 的力量](https://github.com/Tencent/omi/blob/master/tutorial/the-power-of-web-components.cn.md)
2018-11-28 17:59:50 +08:00
* [ShadowRoot](https://developer.mozilla.org/zh-CN/docs/Web/API/ShadowRoot)
2018-12-04 14:41:00 +08:00
* [Developer Tools support for Web Components in Firefox 63](https://blog.nightly.mozilla.org/2018/09/06/developer-tools-support-for-web-components-in-firefox-63/)
2018-10-15 09:45:24 +08:00
---
2018-11-06 08:54:17 +08:00
# 目录
2018-10-26 22:18:48 +08:00
- [Omi 生态](#omi-生态)
2018-11-06 08:39:32 +08:00
- [必须收藏的资源](#必须收藏的资源)
2018-10-17 10:13:28 +08:00
- [一个 HTML 完全上手](#一个-html-完全上手)
2018-10-20 11:38:02 +08:00
- [快速入门](#快速入门)
2018-10-25 21:30:18 +08:00
- [安装](#安装)
2018-11-25 21:34:42 +08:00
- [项目模板](#项目模板)
2018-10-25 21:30:18 +08:00
- [Hello Element](#hello-element)
- [生命周期](#生命周期)
2018-10-20 11:38:02 +08:00
- [调试工具](#调试工具)
2018-10-15 15:05:34 +08:00
- [浏览器兼容](#浏览器兼容)
2018-10-20 11:38:02 +08:00
- [相关链接](#相关链接)
2018-11-26 19:10:02 +08:00
- [贡献者们](#贡献者们)
2018-12-14 09:08:04 +08:00
- [维护者](#维护者)
2018-10-29 14:58:04 +08:00
- [感谢](#感谢)
2018-10-15 09:45:24 +08:00
- [License](#license)
2018-10-17 10:13:28 +08:00
## 一个 HTML 完全上手
2018-10-17 12:59:27 +08:00
下面这个页面不需要任何构建工具就可以执行
2019-09-30 12:21:24 +08:00
- [→ Online Demo!](https://codepen.io/omijs/pen/PMZWNb)
2019-04-21 11:54:31 +08:00
```html
<!DOCTYPE html>
<html>
<head>
<title>Omi demo without transpiler</title>
</head>
<body>
2020-04-18 18:02:38 +08:00
<script src="https://unpkg.com/omi"></script>
<script>
2020-04-18 18:04:27 +08:00
const { define, render, h } = Omi
2020-04-18 18:02:38 +08:00
class Store {
data = {
count: 1
}
sub = () => {
this.data.count--
}
add = () => {
this.data.count++
}
}
define('my-counter', _ => (
h(h.f, null,
h('button', {
onClick: _.store.sub
}, '-'),
h('span', null, _.store.data.count),
h('button', {
onClick: _.store.add
}, '+')
)
), {
use: ['count'],
//or using useSelf, useSelf will update self only, exclude children components
//useSelf: ['count'],
css: `span { color: red; }`,
installed() {
console.log('installed')
}
})
render(h('my-counter'), 'body', new Store)
</script>
2018-10-17 10:13:28 +08:00
</body>
</html>
```
2018-10-15 09:45:24 +08:00
2019-09-30 12:10:15 +08:00
通过上面脚本的执行,你已经定义好了一个自定义标签,可以不使用 render 方法,直接使用 `<my-counter></my-counter>` 标签:
2018-10-19 15:51:45 +08:00
```jsx
<body>
2019-09-30 12:10:15 +08:00
<my-counter></my-counter>
2018-10-19 15:51:45 +08:00
</body>
```
2018-10-31 19:44:01 +08:00
2018-10-20 11:38:02 +08:00
## 快速入门
2018-10-15 09:45:24 +08:00
2018-10-20 11:38:02 +08:00
### 安装
2018-10-16 19:40:30 +08:00
2019-09-20 16:48:28 +08:00
```bash
2019-03-27 09:08:16 +08:00
$ npm i omi-cli -g # install cli
$ omi init my-app # 初始化项目,也可以在空目录里执行 'omi init'
$ cd my-app # 如果在空目录里执行 'omi init' 忽略这条命令
$ npm start # 开发
$ npm run build # 编译发布
2018-10-16 19:40:30 +08:00
```
2018-11-25 15:30:24 +08:00
> `npx omi-cli init my-app` 也支持(要求 npm v5.2.0+)
2018-11-21 22:43:27 +08:00
2018-10-19 18:39:06 +08:00
目录说明:
```
├─ config
├─ public
├─ scripts
├─ src
│ ├─ assets
│ ├─ elements //存放所有 custom elements
│ ├─ store //存放所有页面的 store
│ ├─ admin.js //入口文件,会 build 成 admin.html
│ └─ index.js //入口文件,会 build 成 index.html
```
2019-01-08 11:57:08 +08:00
#### Scripts
```json
"scripts": {
"start": "node scripts/start.js",
"build": "PUBLIC_URL=. node scripts/build.js",
"build-windows": "set PUBLIC_URL=.&& node scripts/build.js",
"fix": "eslint src --fix"
}
```
你也可以设置 PUBLIC_URL, 比如:
```json
...
"build": "PUBLIC_URL=https://fe.wxpay.oa.com/dv node scripts/build.js",
"build-windows": "set PUBLIC_URL=https://fe.wxpay.oa.com/dv&& node scripts/build.js",
...
```
2019-04-26 09:35:45 +08:00
#### 切换 omi, omio 和 reomi
2019-01-15 14:36:37 +08:00
增加或删除 package.json 里的 alias config 可以切换 omi 和 omio 渲染:
```js
2019-04-25 11:33:05 +08:00
"alias": {
"omi": "omio"
}
```
2019-01-08 11:57:08 +08:00
<!-- 关于编译网站的 url 前缀的设置,可以参考两个地址:
2018-10-29 11:55:16 +08:00
* [build problem](https://stackoverflow.com/questions/42686149/create-react-app-build-with-public-url)
2018-10-29 14:51:38 +08:00
* [build env doc](https://facebook.github.io/create-react-app/docs/adding-custom-environment-variables#referencing-environment-variables-in-the-html)
2018-10-29 11:55:16 +08:00
比如在 windows 下:
```json
"scripts": {
"start": "node scripts/start.js",
"_build": "node scripts/build.js",
"build":"set PUBLIC_URL=https://fe.wxpay.oa.com/dv&& npm run _build"
}
```
2018-11-06 22:37:08 +08:00
在 mac os 中:
```json
"scripts": {
"start": "node scripts/start.js",
"_build": "node scripts/build.js",
"build":"PUBLIC_URL=https://fe.wxpay.oa.com/dv npm run _build",
"fix": "eslint src --fix"
},
```
2018-10-29 11:55:16 +08:00
2018-12-13 15:47:26 +08:00
如果你只想使用相对地址:
```
"build":"set PUBLIC_URL=.&& npm run _build" //windows
"build":"PUBLIC_URL=. npm run _build", //mac os
2019-08-18 22:02:49 +08:00
``` -->
2018-12-13 15:47:26 +08:00
2018-11-25 21:33:52 +08:00
### 项目模板
| **Template Type**| **Command**| **Describe**|
| ------------ | -----------| ----------------- |
2019-01-11 11:39:12 +08:00
|基础模板(v3.3.0+)|`omi init my-app`| 基础模板,支持 omi 和 omio(IE8+)|
2019-03-04 10:21:59 +08:00
|小程序模板(v3.3.5+)|`omi init-p my-app`| Omi 开发小程序 |
2019-03-22 11:11:57 +08:00
|基础模板(v3.3.9+)|`omi init-o my-app`| 支持 IE8 的基础模板,只是 build 的时候支持 IE8开发调试请用 IE9|
2019-09-30 12:40:09 +08:00
|Kbone Template|`omi init-kbone my-app` | 使用 omi 开发小程序或者 Web|
2019-01-11 11:39:12 +08:00
|支持预渲染快照骨架的模板|`omi init-snap my-app`| 基础模板,支持 omi 和 omio(IE8+),内置预渲染|
2019-01-07 11:34:15 +08:00
|TypeScript Template(omi-cli v3.3.0+)|`omi init-ts my-app`|使用 TypeScript 的模板|
2018-12-14 16:53:24 +08:00
|Mobile Template|`omi init-weui my-app`| 使用了 weui 和 omi-router 的移动 web app 模板|
2018-11-13 19:56:41 +08:00
2019-09-30 14:39:18 +08:00
2018-10-18 14:16:55 +08:00
2018-10-17 09:28:02 +08:00
### Hello Element
2018-10-15 09:45:24 +08:00
先创建一个自定义元素:
2019-09-20 16:48:28 +08:00
```js
2018-10-30 09:08:59 +08:00
import { define, WeElement } from 'omi'
2018-10-15 09:45:24 +08:00
2018-10-30 09:08:59 +08:00
define('hello-element', class extends WeElement {
onClick = evt => {
// trigger CustomEvent
this.fire('Abc', { name: 'dntzhang', age: 12 })
2018-10-30 09:08:59 +08:00
evt.stopPropagation()
}
2018-10-15 09:45:24 +08:00
2019-06-01 08:57:23 +08:00
//如果需要在 html 里直接使用 <hello-element></hello-element>,必须声明 propTypes
static propTypes = {
msg: String
}
2019-03-25 16:56:40 +08:00
static css = `
2019-01-15 11:41:00 +08:00
div {
color: red;
cursor: pointer;
}`
2018-10-15 09:45:24 +08:00
2018-10-30 09:08:59 +08:00
render(props) {
return (
<div onClick={this.onClick}>
2019-06-01 08:57:23 +08:00
Hello {props.msg}
2018-10-30 09:08:59 +08:00
<div>Click Me!</div>
</div>
)
}
})
2018-10-15 09:45:24 +08:00
```
使用该元素:
2018-10-30 09:08:59 +08:00
```js
import { define, render, WeElement } from 'omi'
2018-10-15 09:45:24 +08:00
import './hello-element'
2018-10-30 09:08:59 +08:00
define('my-app', class extends WeElement {
2019-06-01 08:57:23 +08:00
data = { abc: 'abc' }
2018-10-15 09:45:24 +08:00
2018-10-30 09:08:59 +08:00
// define CustomEvent Handler
onAbc = evt => {
// get evt data by evt.detail
this.data.abc = ' by ' + evt.detail.name
this.update()
}
2018-10-15 09:45:24 +08:00
2019-06-01 08:57:23 +08:00
static css = `
2019-01-15 11:41:00 +08:00
div{
color: green;
}`
2018-10-15 09:45:24 +08:00
render(props) {
2018-10-30 09:08:59 +08:00
return (
<div>
Hello {this.data.abc}
2018-10-30 09:08:59 +08:00
<hello-element
onAbc={this.onAbc}
msg="WeElement"
/>
</div>
)
}
})
2018-10-15 09:45:24 +08:00
2018-10-30 09:08:59 +08:00
render(<my-app name="Omi v4.0" />, 'body')
2018-10-15 09:45:24 +08:00
```
告诉 Babel 把 JSX 转化成 Omi.h() 的调用:
``` json
{
"presets": ["env", "omi"]
}
```
需要安装下面两个 npm 包支持上面的配置:
``` bash
"babel-preset-env": "^1.6.0",
"babel-preset-omi": "^0.1.1",
```
2018-10-27 16:08:24 +08:00
如果你使用 babel7也可以使用如下包和配置
```bash
npm install --save-dev @babel/preset-env
npm install --save-dev @babel/preset-react
```
```js
{
"presets": [
"@babel/preset-env",
[
"@babel/preset-react",
{
2019-10-15 19:27:43 +08:00
"pragma": "Omi.h",
"pragmaFrag": "Omi.h.f"
2018-10-27 16:08:24 +08:00
}
]
]
}
```
2018-10-15 09:45:24 +08:00
2018-10-23 09:18:59 +08:00
如果不想把 css 写在 js 里,你可以使用 webpack [to-string-loader](https://www.npmjs.com/package/to-string-loader), 比如下面配置:
2018-10-15 09:45:24 +08:00
``` js
{
test: /[\\|\/]_[\S]*\.css$/,
use: [
'to-string-loader',
'css-loader'
]
}
```
2019-09-26 16:29:08 +08:00
如果你的 css 文件以 `_` 开头, css 会使用 to-string-loader, 如:
2018-10-15 09:45:24 +08:00
``` js
2018-10-16 00:11:10 +08:00
import { tag, WeElement render } from 'omi'
2018-10-15 09:45:24 +08:00
2019-01-15 11:41:00 +08:00
define('my-app', class extends WeElement {
2018-10-15 09:45:24 +08:00
2019-01-15 11:41:00 +08:00
css = require('./_index.css')
2018-10-15 09:45:24 +08:00
...
...
...
```
2018-10-27 16:12:05 +08:00
你也可以忘掉这一对繁琐的配置直接使用 omi-cli不需要你配置任何东西。
2019-09-30 12:01:52 +08:00
<!-- ### TodoApp
2018-10-15 09:45:24 +08:00
下面列举一个相对完整的 TodoApp 的例子:
```js
2018-11-03 06:49:36 +08:00
import { define, render, WeElement } from 'omi'
2018-10-15 09:45:24 +08:00
2019-06-01 09:01:35 +08:00
define('todo-list', class extends WeElement {
static propTypes = {
items: Array
}
render(props) {
return (
<ul>
{props.items.map(item => (
<li key={item.id}>{item.text}</li>
))}
</ul>
)
}
2018-10-30 06:42:07 +08:00
})
define('todo-app', class extends WeElement {
2019-08-06 12:30:44 +08:00
items = []
text = ''
2018-10-30 07:01:01 +08:00
render() {
return (
<div>
<h3>TODO</h3>
2019-08-06 12:30:44 +08:00
<todo-list items={this.items} />
2018-10-30 07:01:01 +08:00
<form onSubmit={this.handleSubmit}>
<input
id="new-todo"
onChange={this.handleChange}
2019-08-06 12:30:44 +08:00
value={this.text}
2018-10-30 07:01:01 +08:00
/>
2019-08-06 12:30:44 +08:00
<button>Add #{this.items.length + 1}</button>
2018-10-30 07:01:01 +08:00
</form>
</div>
)
}
handleChange = e => {
2019-08-06 12:30:44 +08:00
this.text = e.target.value
2018-10-30 07:01:01 +08:00
}
handleSubmit = e => {
e.preventDefault()
2019-08-06 12:30:44 +08:00
if (!this.text.trim().length) {
2018-10-30 07:01:01 +08:00
return
}
2019-08-06 12:30:44 +08:00
this.items.push({
text: this.text,
2018-10-30 07:01:01 +08:00
id: Date.now()
})
2019-08-06 12:30:44 +08:00
this.text = ''
this.update()
2018-10-30 07:01:01 +08:00
}
2018-10-30 06:42:07 +08:00
})
render(<todo-app />, 'body')
2019-09-30 12:01:52 +08:00
``` -->
<!--
2018-10-16 13:44:49 +08:00
使用 Store 体系可以告别 update 方法,基于 Proxy 的全自动属性追踪和更新机制。强大的 Store 体系是高性能的原因,除了靠 props 决定组件状态的组件,其余组件所有 data 都挂载在 store 上,
2018-10-15 09:45:24 +08:00
```js
export default {
data: {
items: [],
text: '',
firstName: 'dnt',
lastName: 'zhang',
fullName: function () {
return this.firstName + this.lastName
},
globalPropTest: 'abc', //更改我会刷新所有页面,不需要再组件和页面声明data依赖
ccc: { ddd: 1 } //更改我会刷新所有页面,不需要再组件和页面声明data依赖
},
2018-10-15 10:19:45 +08:00
globalData: ['globalPropTest', 'ccc.ddd'],
2018-10-15 09:45:24 +08:00
add: function () {
if (!this.data.text.trim().length) {
return;
}
this.data.items.push({
text: this.data.text,
id: Date.now()
})
this.data.text = ''
2018-10-15 10:19:45 +08:00
}
2018-10-15 09:45:24 +08:00
//默认 false为 true 会无脑更新所有实例
//updateAll: true
}
```
自定义 Element 需要声明依赖的 data这样 Omi store 根据自定义组件上声明的 data 计算依赖 path 并会按需局部更新。如:
```js
2018-10-30 09:15:43 +08:00
define('todo-app', class extends WeElement {
2018-10-15 09:45:24 +08:00
static get data() {
2018-10-16 19:10:13 +08:00
//如果你用了 store这个只是用来声明依赖按需 Path Updating
2018-10-15 09:45:24 +08:00
return { items: [], text: '' }
}
...
...
...
handleChange = (e) => {
this.store.data.text = e.target.value
}
handleSubmit = (e) => {
e.preventDefault()
this.store.add()
}
2018-10-30 09:15:43 +08:00
})
2018-10-15 09:45:24 +08:00
```
* 数据的逻辑都封装在了 store 定义的方法里 (如 store.add)
* 视图只负责传递数据给 store (如上面调用 store.add 或设置 store.data.text
需要在 render 的时候从根节点注入 store 才能在所有自定义 Element 里使用 this.store:
```js
render(<todo-app></todo-app>, 'body', store)
```
2018-10-17 09:14:52 +08:00
[→ Store 完整的代码](https://github.com/Tencent/omi/blob/master/packages/omi/examples/store/main.js)
2018-10-15 09:45:24 +08:00
总结一下:
* store.data 用来列出所有属性和默认值(除去 props 决定的视图的组件)
2019-08-18 22:02:49 +08:00
* 组件和页面的 data 用来列出依赖的 store.data 的属性 (omi 会记录 path),按需更新
2018-10-15 09:45:24 +08:00
* 如果页面简单组件很少,可以 updateAll 设置成 true并且组件和页面不需要声明 data也就不会按需更新
* globalData 里声明的 path只要修改了对应 path 的值就会刷新所有页面和组件globalData 可以用来列出所有页面或大部分公共的属性 Path -->
2019-03-25 16:59:37 +08:00
<!--
2018-11-21 09:19:12 +08:00
## Mitt
如果不想使用 store 的 data 体系,也可以使用发布订阅模式。比如在 Omi 中使用 [mitt](https://github.com/developit/mitt) 跨组件通讯:
2019-03-25 16:59:37 +08:00
* [cross-component-communication](https://github.com/Tencent/omi/blob/master/packages/omi-30-seconds/README.md#cross-component-communication) -->
2018-11-21 09:19:12 +08:00
2018-12-24 09:47:09 +08:00
<!--
2018-11-01 15:12:52 +08:00
如果你想要兼容 IE11,请使用 `omi-mobx` 代替 omi 自带的 observe往下看..
2018-10-21 17:19:49 +08:00
2018-10-28 08:19:56 +08:00
### Omi Mobx
2018-10-21 17:19:49 +08:00
```js
2018-10-28 08:19:56 +08:00
import { tag, WeElement } from "omi"
import { observe } from "omi-mobx"
2018-10-21 17:19:49 +08:00
@observe
2018-10-28 08:19:56 +08:00
@tag("my-app")
2018-10-21 17:19:49 +08:00
class MyApp extends WeElement {
install() {
2018-10-28 08:19:56 +08:00
this.data.name = "omi"
2018-10-21 17:19:49 +08:00
}
onClick = () => {
2018-10-28 08:19:56 +08:00
this.data.name = "Omi V4.0"
2018-10-21 17:19:49 +08:00
}
render(props, data) {
return (
<div onClick={this.onClick}>
2018-10-28 08:19:56 +08:00
<h1>Welcome to {data.name}</h1>
2018-10-21 17:19:49 +08:00
</div>
)
}
}
2019-08-18 22:02:49 +08:00
``` -->
2018-10-21 17:19:49 +08:00
2018-10-28 08:19:56 +08:00
### 生命周期
2019-06-07 15:30:24 +08:00
| 钩子方法 | 触发时机 |
2018-10-28 08:19:56 +08:00
| ---------------- | -------------------------------------------- |
2019-06-07 15:30:24 +08:00
| `install` | 初始化安装 |
| `installed` | 插入到文档之后且安装完成 |
| `uninstall` | 从文档中卸载移除 |
| `beforeUpdate` | update 之前 |
| `updated` | update 之后 |
| `beforeRender` | `render()` 之前 |
| `receiveProps` | 父组件更新时候触发, 返回 false 可以阻止更新 |
2018-10-28 08:19:56 +08:00
## 调试工具
使用 [Omi 开发工具](https://chrome.google.com/webstore/detail/omijs-devtools/pjgglfliglbhpcpalbpeloghnbceocmd) 可以非常简单地调试和管理你的 UI。不需要任何配置你只要安装然后就能调试。
2018-12-31 17:15:55 +08:00
既然 Omi 使用了 Web Components 和 Shadow-DOM, 所以不需要像 React 一样安装其他元素面板,只需要使用 Chrome 自带的 **Elements' sidebar** 便可,它和 React 开发者工具一样强大。
2018-10-28 08:19:56 +08:00
![Omi DevTools](https://github.com/f/omi-devtools/raw/master/omi-devtools.gif)
2019-05-26 09:08:12 +08:00
### 查看所有注册的元素
2019-09-20 16:48:28 +08:00
```js
2019-05-26 09:08:12 +08:00
console.log(Omi.elements)
```
2019-03-25 16:58:16 +08:00
<!--
2018-11-05 13:14:43 +08:00
## React 组件转成 Omi
举个例子,下面是吧 weui react 的 button 转成 weui omi 的 button 的例子 :
![react to omi](./assets/react-to-omi.png)
* [Diff Split](https://github.com/Tencent/omi/commit/9790fadaaf20cfede80bcf9213756a83fc8c3949?diff=split)
* [Diff Unified](https://github.com/Tencent/omi/commit/9790fadaaf20cfede80bcf9213756a83fc8c3949?diff=unified)
* [Before](https://github.com/Tencent/omi/blob/c8af654f1d5865dc557c0b4b8ad524f702a69be5/packages/omi-weui/src/omi-weui/elements/button/button.js)
2019-03-25 16:58:16 +08:00
* [After](https://github.com/Tencent/omi/blob/9790fadaaf20cfede80bcf9213756a83fc8c3949/packages/omi-weui/src/omi-weui/elements/button/button.js) -->
2018-11-05 13:14:43 +08:00
2018-10-15 15:05:34 +08:00
## 浏览器兼容
2018-10-15 11:53:32 +08:00
2019-08-18 22:02:49 +08:00
> [Omio](https://github.com/Tencent/omi/tree/master/packages/omio) - 兼容老浏览器的 Omi 版本(支持到 IE8+)
2018-12-13 16:15:47 +08:00
2019-09-13 09:17:25 +08:00
Omi works in the latest two versions of all major browsers: Safari 10+, IE 11+, and the evergreen Chrome, Firefox, and Edge.
2018-10-15 11:53:32 +08:00
2018-10-23 06:47:28 +08:00
![→ Browsers Support](./assets/browsers-support.png)
2018-10-15 11:53:32 +08:00
[→ polyfills](https://github.com/webcomponents/webcomponentsjs)
2018-12-11 14:56:28 +08:00
```html
<script src="https://unpkg.com/@webcomponents/webcomponentsjs@2.0.0/webcomponents-bundle.js"></script>
```
## 贡献
Build a example:
```bash
npm start example_name
```
Build omi:
```bash
npm run build
```
Unit testing
```
npm run test
```
2018-11-26 19:10:02 +08:00
## 贡献者们
<table><tbody>
2019-08-16 15:33:07 +08:00
<tr><td><a target="_blank" href="https://github.com/dntzhang"><img width="60px" src="https://avatars2.githubusercontent.com/u/7917954?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/LeeHyungGeun"><img width="60px" src="https://avatars2.githubusercontent.com/u/2471651?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/xcatliu"><img width="60px" src="https://avatars1.githubusercontent.com/u/5453359?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/1921622004"><img width="60px" src="https://avatars1.githubusercontent.com/u/19359217?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/yanceyou"><img width="60px" src="https://avatars2.githubusercontent.com/u/16320418?s=60&amp;v=4"></a></td></tr><tr><td><a target="_blank" href="https://github.com/f"><img width="60px" src="https://avatars0.githubusercontent.com/u/196477?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/pasturn"><img width="60px" src="https://avatars0.githubusercontent.com/u/6126885?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/Wscats"><img width="60px" src="https://avatars3.githubusercontent.com/u/17243165?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/akira-cn"><img width="60px" src="https://avatars0.githubusercontent.com/u/316498?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/ZainChen"><img width="60px" src="https://avatars3.githubusercontent.com/u/15615524?s=60&amp;v=4"></a></td></tr><tr><td><a target="_blank" href="https://github.com/dangxuandev"><img width="60px" src="https://avatars1.githubusercontent.com/u/5436704?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/daizhan"><img width="60px" src="https://avatars0.githubusercontent.com/u/5318547?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/132yse"><img width="60px" src="https://avatars1.githubusercontent.com/u/12951461?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/elfman"><img width="60px" src="https://avatars3.githubusercontent.com/u/948001?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/NoBey"><img width="60px" src="https://avatars3.githubusercontent.com/u/10740524?s=60&amp;v=4"></a></td></tr><tr><td><a target="_blank" href="https://github.com/hilkbahar"><img width="60px" src="https://avatars2.githubusercontent.com/u/12161006?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/eyea"><img width="60px" src="https://avatars0.githubusercontent.com/u/17020223?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/guisturdy"><img width="60px" src="https://avatars1.githubusercontent.com/u/7098619?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/KidneyFlower"><img width="60px" src="https://avatars1.githubusercontent.com/u/16027183?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/zhangsanshi"><img width="60px" src="https://avatars1.githubusercontent.com/u/3771933?s=60&amp;v=4"></a></td></tr><tr><td><a target="_blank" href="https://github.com/xland"><img width="60px" src="https://avatars0.githubusercontent.com/u/2980915?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/winstonxie"><img width="60px" src="https://avatars3.githubusercontent.com/u/16422642?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/ghostzhang"><img width="60px" src="https://avatars3.githubusercontent.com/u/194242?s=60&amp;v=4"></a></td>
2019-04-29 10:26:21 +08:00
<td><a target="_blank" href="https://github.com/jayZOU"><img width="60px" src="https://avatars3.githubusercontent.com/u/8576977?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/zhengbao"><img width="60px" src="https://avatars3.githubusercontent.com/u/1736166?s=60&amp;v=4"></a></td></tr><tr><td><a target="_blank" href="https://github.com/vorshen"><img width="60px" src="https://avatars3.githubusercontent.com/u/10334783?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/akira-cn"><img width="60px" src="https://avatars3.githubusercontent.com/u/316498?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/loo41"><img width="60px" src="https://avatars3.githubusercontent.com/u/28095677?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/rainmanhhh"><img width="60px" src="https://avatars3.githubusercontent.com/u/13862623?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/nbompetsis"><img width="60px" src="https://avatars3.githubusercontent.com/u/11991105?s=60&amp;v=4"></a></td></tr><tr><td><a target="_blank" href="https://github.com/CodeFalling"><img width="60px" src="https://avatars1.githubusercontent.com/u/5436704?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/daizhan"><img width="60px" src="https://avatars0.githubusercontent.com/u/5318547?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/ritschwumm"><img width="60px" src="https://avatars2.githubusercontent.com/u/547138?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/kahwee"><img width="60px" src="https://avatars3.githubusercontent.com/u/262105?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/alanyinjs"><img width="60px" src="https://avatars3.githubusercontent.com/u/25688258?s=60&amp;v=4"></a></td></tr><tr><td><a target="_blank" href="https://github.com/electerious"><img width="60px" src="https://avatars2.githubusercontent.com/u/499088?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/nanhupatar"><img width="60px" src="https://avatars1.githubusercontent.com/u/27266016?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/ilker0"><img width="60px" src="https://avatars1.githubusercontent.com/u/23511412?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/MrGrabazu"><img width="60px" src="https://avatars2.githubusercontent.com/u/6928672?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/Tagir-A"><img width="60px" src="https://avatars2.githubusercontent.com/u/23556586?s=60&amp;v=4"></a></td></tr><tr><td><a target="_blank" href="https://github.com/mahmut-gundogdu"><img width="60px" src="https://avatars2.githubusercontent.com/u/2217899?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/howel52"><img width="60px" src="https://avatars3.githubusercontent.com/u/9854818?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/yolio2003"><img width="60px" src="https://avatars1.githubusercontent.com/u/352931?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/loo41"><img width="60px" src="https://avatars3.githubusercontent.com/u/28095677?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/nbompetsis"><img width="60px" src="https://avatars1.githubusercontent.com/u/11991105?s=60&amp;v=4"></a></td></tr><tr><td><a target="_blank" href="https://github.com/WozHuang"><img width="60px" src="https://avatars2.githubusercontent.com/u/22727100?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/web-padawan"><img width="60px" src="https://avatars2.githubusercontent.com/u/10589913?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/SuperHuangXu"><img width="60px" src="https://avatars1.githubusercontent.com/u/14816052?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/LastHeaven"><img width="60px" src="https://avatars1.githubusercontent.com/u/10590077?s=60&amp;v=4"></a></td>
2019-08-16 15:30:36 +08:00
<td><a target="_blank" href="https://github.com/validalias"><img width="60px" src="https://avatars3.githubusercontent.com/u/44221844?s=60&amp;v=4"></a></td></tr><tr>
2019-05-12 18:37:14 +08:00
<td><a target="_blank" href="https://github.com/FAKER-A"><img width="60px" src="https://avatars2.githubusercontent.com/u/25676164?s=60&amp;v=4"></a></td>
<td><a target="_blank" href="https://github.com/liulinboyi"><img width="60px" src="https://avatars2.githubusercontent.com/u/41336612?s=60&amp;v=4"></a></td>
2019-11-10 09:15:38 +08:00
<td><a target="_blank" href="https://github.com/hulei"><img width="60px" src="https://avatars2.githubusercontent.com/u/6905072?s=60&amp;v=4"></a></td> <td><a target="_blank" href="https://github.com/mtonhuang"><img width="60px" src="https://avatars2.githubusercontent.com/u/30364922?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/Juliiii"><img width="60px" src="https://avatars2.githubusercontent.com/u/23744602?s=60&amp;v=4"></a></td></tr><tr><td><a target="_blank" href="https://github.com/mingkang1993"><img width="60px" src="https://avatars2.githubusercontent.com/u/9126292?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/liufushihai"><img width="60px" src="https://avatars2.githubusercontent.com/u/28208916?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/supermp"><img width="60px" src="https://avatars2.githubusercontent.com/u/892475?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/LeachZhou"><img width="60px" src="https://avatars2.githubusercontent.com/u/18715564?s=60&amp;v=4"></a></td><td><a target="_blank" href="https://github.com/yiliang114"><img width="60px" src="https://avatars2.githubusercontent.com/u/11473889?s=60&amp;v=4"></a></td></tr>
<tr><td><a target="_blank" href="https://github.com/liubailing"><img width="60px" src="https://avatars2.githubusercontent.com/u/3907493?s=60&amp;v=4"></a></td>
<td><a target="_blank" href="https://github.com/fyuan1992"><img width="60px" src="https://avatars2.githubusercontent.com/u/19830858?s=60&amp;v=4"></a></td>
2020-01-09 16:46:43 +08:00
<td><a target="_blank" href="https://github.com/xinshangshangxin"><img width="60px" src="https://avatars2.githubusercontent.com/u/8779091?s=60&amp;v=4"></a></td>
<td><a target="_blank" href="https://github.com/aolu11"><img width="60px" src="https://avatars2.githubusercontent.com/u/1127488?s=60&amp;v=4"></a></td>
2019-11-10 09:15:38 +08:00
</tr></tbody></table>
2019-05-12 18:37:14 +08:00
2020-04-18 20:21:14 +08:00
感谢所有贡献者,欢迎更多人加入一起贡献。
2019-10-03 16:20:25 +08:00
2019-07-25 20:16:12 +08:00
## 核心维护者
2018-10-20 09:30:19 +08:00
2020-04-30 15:43:18 +08:00
- [AlloyTeam](http://alloyteam.com/)
2019-07-25 20:16:12 +08:00
- [@Wscats](https://github.com/Wscats)
2018-10-25 12:51:40 +08:00
- [@f](https://github.com/f)
2018-11-01 10:43:37 +08:00
- [@LeeHyungGeun](https://github.com/LeeHyungGeun)
2018-10-25 12:51:40 +08:00
- [@dntzhang](https://github.com/dntzhang)
2018-10-25 11:38:56 +08:00
- [@xcatliu](https://github.com/xcatliu)
2018-10-20 11:12:43 +08:00
2018-11-11 14:03:54 +08:00
任何 Omi 相关问题欢迎联系我们。也可以[加入 Omi QQ 群](https://github.com/Tencent/omi/issues/169)进行讨论交流。
2018-11-10 14:44:23 +08:00
2018-10-29 14:58:04 +08:00
## 感谢
* [preact](https://github.com/developit/preact)
2019-10-23 09:25:36 +08:00
* [obaa](https://github.com/Tencent/omi/tree/master/packages/obaa)
2018-11-12 15:53:48 +08:00
* [create-react-app](https://github.com/facebook/create-react-app)
* [JSX](https://github.com/facebook/jsx)
2019-04-25 11:13:29 +08:00
* [JSONPatcherProxy](https://github.com/Palindrom/JSONPatcherProxy)
2018-10-29 14:58:04 +08:00
2018-10-20 11:12:43 +08:00
## License
2018-10-25 20:23:25 +08:00
MIT © Tencent