From d7bdb3c06d9b05643a6f72b2cfafb2e7606e37f4 Mon Sep 17 00:00:00 2001 From: Amour1688 Date: Fri, 3 Jul 2020 00:51:53 +0800 Subject: [PATCH] docs: Update docs --- README-zh_CN.md | 124 +++++++++++++++++++++++++++ README.md | 125 ++++++++++++++++++++++++++++ packages/babel-plugin-jsx/README.md | 2 +- 3 files changed, 250 insertions(+), 1 deletion(-) diff --git a/README-zh_CN.md b/README-zh_CN.md index 6f6b8a9..cccf492 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -34,6 +34,130 @@ npm install @ant-design-vue/babel-helper-vue-transform-on 开启这个参数意味着对 { attrs, props, on } 做了兼容处理,但是所有的属性外层都会有 `compatibleProps` 方法 +## 表达式 + +### 内容 +函数式组件 + +```jsx +const App = () =>
+``` + +在 render 中使用 + +```jsx +const App = { + render() { + return
Vue 3.0
+ } +} +``` + +```jsx +const App = defineComponent(() => { + const count = ref(0); + + const inc = () => { + count.value++; + }; + + return () => ( +
+ {count.value} +
+ ) +}) +``` + +Fragment + +```jsx +const App = () => ( + <> + I'm + Fragment + +) +``` + +### Attributes/Props + +```jsx +const App = () => +``` + +with a dynamic binding: + +```jsx +const placeholderText = 'email' +const App = () => ( + +) +``` + +### 指令 + +> 建议在 JSX 中使用驼峰 (`vModel`),但是 `v-model` 也能用 + +v-show + +```jsx +const App = { + data() { + return { visible: true }; + }, + render() { + return ; + }, +}; +``` + +v-model + +* 修饰符:使用 (`_`) 代替 (`.`) (`vModel_trim={this.test}`) + +```jsx +export default { + data: () => ({ + test: 'Hello World', + }), + render() { + return ( + <> + + {this.test} + + ) + }, +} +``` + +自定义指令 + +```jsx +const App = { + directives: { custom: customDirective }, + setup() { + return () => ( + + ); + }, +} +``` + +### 插槽 + +目前功能没有想好怎么实现,欢迎在 issue 中讨论,可以先使用 `props` 来代替 + ## 兼容性 要求: diff --git a/README.md b/README.md index e6e3315..6530783 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,131 @@ compatible with Vue 2.x `{ props, on = {}, attrs, ...rest }` will be transformed to `{ ...props, ...attrs, ...transformOn(on), ...rest }` +## Syntax + +### Content +functional component + +```jsx +const App = () =>
+``` + +with render + +```jsx +const App = { + render() { + return
Vue 3.0
+ } +} +``` + +```jsx +const App = defineComponent(() => { + const count = ref(0); + + const inc = () => { + count.value++; + }; + + return () => ( +
+ {count.value} +
+ ) +}) +``` + +Fragment + +```jsx +const App = () => ( + <> + I'm + Fragment + +) +``` + +### Attributes/Props + +```jsx +const App = () => +``` + +with a dynamic binding: + +```jsx +const placeholderText = 'email' +const App = () => ( + +) +``` + +### Directives + +> It is recommended to use camelCase version of it (`vModel`) in JSX, but you can use kebab-case too (`v-model`). + +v-show + +```jsx +const App = { + data() { + return { visible: true }; + }, + render() { + return ; + }, +}; +``` + +v-model + +* You should use underscore (`_`) instead of dot (`.`) for modifiers (`vModel_trim={this.test}`) + +```jsx +export default { + data: () => ({ + test: 'Hello World', + }), + render() { + return ( + <> + + {this.test} + + ) + }, +} +``` + +custom directive + +```jsx +const App = { + directives: { custom: customDirective }, + setup() { + return () => ( +
+ ); + }, +} +``` + +### Slot + +Why Not props ? + + ## Compatibility This repo is only compatible with: diff --git a/packages/babel-plugin-jsx/README.md b/packages/babel-plugin-jsx/README.md index 2eb634c..1c28d68 100644 --- a/packages/babel-plugin-jsx/README.md +++ b/packages/babel-plugin-jsx/README.md @@ -53,7 +53,7 @@ const App = defineComponent(() => { }) ``` -fragment +Fragment ```jsx const App = () => (