From 277fadfc198c004935594301b927378e99600e69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=A3=8A?= Date: Wed, 31 Oct 2018 17:39:18 +0800 Subject: [PATCH] update readme --- README.CN.md | 25 +++++++++++++++++++++++++ README.md | 25 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/README.CN.md b/README.CN.md index c5181e8a2..794bb782d 100644 --- a/README.CN.md +++ b/README.CN.md @@ -208,6 +208,31 @@ define('my-counter', class extends WeElement { render(, 'body') ``` +你也可以定义成纯函数的形式: + +```js +import { define, render } from 'omi' + +define('my-counter', function() { + const [count, setCount] = this.use({ + data: 0, + effect: function() { + document.title = `The num is ${this.data}.` + } + }) + + return ( +
+ + {count} + +
+ ) +}) + +render(, 'body') +``` + ## 快速入门 ### 安装 diff --git a/README.md b/README.md index 0917419c4..23ff790bc 100644 --- a/README.md +++ b/README.md @@ -206,6 +206,31 @@ define('my-counter', class extends WeElement { render(, 'body') ``` +You can also be defined as a form of pure functions: + +```js +import { define, render } from 'omi' + +define('my-counter', function() { + const [count, setCount] = this.use({ + data: 0, + effect: function() { + document.title = `The num is ${this.data}.` + } + }) + + return ( +
+ + {count} + +
+ ) +}) + +render(, 'body') +``` + ## Getting Started ### Install