mirror of
https://github.com/vuejs/babel-plugin-jsx.git
synced 2024-11-10 09:39:14 +08:00
docs: add zh-CN.md
This commit is contained in:
parent
290c56ae96
commit
33ff92fd87
42
README-zh_CN.md
Normal file
42
README-zh_CN.md
Normal file
@ -0,0 +1,42 @@
|
||||
# Vue 3 Babel JSX 插件
|
||||
|
||||
以 JSX 的方式来编写 Vue 代码
|
||||
|
||||
## 安装
|
||||
|
||||
安装插件
|
||||
|
||||
```
|
||||
npm install @ant-design-vue/babel-plugin-jsx -D
|
||||
|
||||
npm install @ant-design-vue/babel-helper-vue-transform-on
|
||||
```
|
||||
|
||||
配置 Babel
|
||||
|
||||
```
|
||||
{
|
||||
"plugins": ["@ant-design-vue/babel-plugin-jsx"]
|
||||
}
|
||||
```
|
||||
|
||||
## 使用
|
||||
|
||||
### 参数
|
||||
|
||||
* transformOn
|
||||
|
||||
把 `on: { click: xx }` 转成 `onClick: xxx`
|
||||
|
||||
* compatibleProps
|
||||
|
||||
兼容大多数 Vue 2 的写法,Vue 3 中,把所有属性都改成了顶级属性,意味这不需要再传递 props,attrs 这些属性。
|
||||
|
||||
开启这个参数意味着对 { attrs, props, on } 做了兼容处理,但是所有的属性外层都会有 `compatibleProps` 方法
|
||||
|
||||
## 兼容性
|
||||
|
||||
要求:
|
||||
|
||||
- **Babel 7+**
|
||||
- **Vue 3+**
|
@ -2,6 +2,8 @@
|
||||
|
||||
To add Vue JSX support.
|
||||
|
||||
English | [简体中文](./README-zh_CN.md)
|
||||
|
||||
## Installation
|
||||
|
||||
Install the plugin with:
|
||||
@ -16,7 +18,7 @@ Then add the plugin to .babelrc:
|
||||
|
||||
```
|
||||
{
|
||||
"plugins": ["@ant-design-vue/babel-plugin-jsx", { "transformOn": true, "compatibleProps": true }]
|
||||
"plugins": ["@ant-design-vue/babel-plugin-jsx"]
|
||||
}
|
||||
```
|
||||
|
||||
@ -31,6 +33,8 @@ transform `on: { click: xx }` to `onClick: xxx`
|
||||
|
||||
compatible with Vue 2.x
|
||||
|
||||
`{ props, on = {}, attrs, ...rest }` will be transformed to `{ ...props, ...attrs, ...transformOn(on), ...rest }`
|
||||
|
||||
## Compatibility
|
||||
|
||||
This repo is only compatible with:
|
||||
|
Loading…
Reference in New Issue
Block a user