Skip to content

Commit 5bd2aa1

Browse files
committed
docs: update docs and some log
1 parent fab7e50 commit 5bd2aa1

12 files changed

+117
-140
lines changed

README_ZH.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# vue-codemod
22

3-
> ️注意: 该仓库 fork 自 [https://github.com/vuejs/vue-codemod](https://github.com/vuejs/vue-codemod)
3+
> ️ 注意: 该仓库 fork 自 [https://github.com/vuejs/vue-codemod](https://github.com/vuejs/vue-codemod)
44
55
`vue-codemod` 是一个 `Vue2` 升级 `Vue3` 的语法转换工具,能将绝大多数 `Vue2` 语法直接升级成 `Vue3` 语法,然后通过少量的手动修改完成 `Vue2``Vue3` 的平滑迁移。
66

@@ -35,7 +35,7 @@
3535
3636
#### `npm/yarn` 方式
3737

38-
``` bash
38+
```bash
3939
npm install @originjs/vue-codemod -g
4040
//or
4141
yarn global add @originjs/vue-codemod
@@ -73,7 +73,7 @@ yarn global add .
7373

7474
`vue-codemod` 是由一条条转换规则组成,这些转换规则位于 `transformation/index.ts``vue-transformation/index.ts` 下。
7575

76-
``` bash
76+
```bash
7777
npx vue-codemod <path> -t/-a [transformation params][...additional options]
7878
```
7979

@@ -82,7 +82,7 @@ npx vue-codemod <path> -t/-a [transformation params][...additional options]
8282

8383
#### 执行所有规则
8484

85-
``` bash
85+
```bash
8686
npx vue-codemod src -a
8787
```
8888

@@ -137,7 +137,7 @@ npx vue-codemod src -a -f log
137137

138138
#### 手动迁移指导
139139

140-
`vue-codemod`的运行过程中,会识别到需要手动修改的部分,并以对象的形式打印到控制台(如果有`-f log`命令,则会输出到log文件中),样例如下:
140+
`vue-codemod`的运行过程中,会识别到需要手动修改的部分,并以对象的形式打印到控制台(如果有`-f log`命令,则会输出到 log 文件中),样例如下:
141141

142142
```null
143143
The list that you need to migrate your codes mannually:
@@ -159,7 +159,7 @@ npx vue-codemod --help
159159

160160
结果如下所示
161161

162-
``` bash
162+
```bash
163163
npx vue-codemod --help
164164
Usage: vue-codemod [file pattern]
165165

docs/manual-guide.md

Lines changed: 53 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
- [Manual Migration Guide](#Manual-Migration-Guide)
2-
- [Limitation](#Limitation)
3-
- [Vue version](#Vue-version)
4-
- [Third-party dependencies](#Third-party-dependencies)
1+
- [Manual Migration Guide](#manual-migration-guide)
2+
- [Limitation](#limitation)
3+
- [Vue version](#vue-version)
4+
- [Third-party dependencies](#third-party-dependencies)
55
- [Vue](#vue)
6-
- [Global API](#Global-API)
7-
- [Slot](#Slot)
8-
- [Filter](#Filter)
9-
- [Partial Filter](#Partial-Filter)
10-
- [Global Filter](#Global-Filter)
11-
- [Events API](#Events-api)
6+
- [Global API](#global-api)
7+
- [Slot](#slot)
8+
- [Filter](#filter)
9+
- [Partial Filter](#partial-filter)
10+
- [Global Filter](#global-filter)
11+
- [Events API](#events-api)
1212
- [/deep/](#deep)
13-
- [Delimiter](#Delimiter)
13+
- [Delimiter](#delimiter)
1414
- [Vue Router](#vue-router)
1515
- [VueRouter.prototype](#vuerouterprototype)
16-
- [Removed `*` routes](#Removed-`*`-routes)
17-
- [All navigations in Router 4 are asynchronous](#All-navigations-in-Router-4-are-asynchronous)
16+
- [Removed `*` routes](#removed--routes)
17+
- [All navigations in Router 4 are asynchronous](#all-navigations-in-router-4-are-asynchronous)
1818
- [Element-ui](#element-ui)
19-
- [Upgrade Dependencies](#Upgrade-Dependencies)
20-
- [Import Modules](#Import-Modules)
21-
- [`slot` attribute in el-table](#`slot`-attribute-in-el-table)
19+
- [Import CSS](#import-css)
20+
- [`slot` attribute in el-table](#slot-attribute-in-el-table)
2221

2322
<!-- /TOC -->
2423

@@ -38,7 +37,7 @@ Vue version >= 2.6.0
3837

3938
Some third-party packages currently don't have support for Vue 3
4039

41-
Currently, the UI framework libraries that support Vue 3 are:
40+
Currently, the UI framework libraries that support Vue 3 are:
4241

4342
- [quasar](https://github.com/quasarframework/quasar)
4443
- [element-plus](https://github.com/element-plus/element-plus/)
@@ -50,7 +49,7 @@ Please refer to [Vue2ToVue3](https://github.com/zdravkov/Vue2ToVue3) to see the
5049

5150
### Global API
5251

53-
[Migration Guide from Vue.js team](https://v3.vuejs.org/guide/migration/global-api.html)
52+
[Migration Guide from Vue.js team](https://v3.vuejs.org/guide/migration/global-api.html)
5453

5554
- Transform `Global API` to a plugin
5655

@@ -60,22 +59,22 @@ Please refer to [Vue2ToVue3](https://github.com/zdravkov/Vue2ToVue3) to see the
6059

6160
```js
6261
// directive/index.js
63-
import Vue from "vue";
64-
import myDirective from "@/directive/myDirective";
62+
import Vue from 'vue'
63+
import myDirective from '@/directive/myDirective'
6564

66-
Vue.directive('myDirective', myDirective) ;
65+
Vue.directive('myDirective', myDirective)
6766
```
6867

6968
In Vue 3:
7069

7170
```js
7271
// directive/index.js
73-
import myDirective from "@/directive/myDirective";
72+
import myDirective from '@/directive/myDirective'
7473
75-
export default{
76-
install: app => {
77-
app.directive('myDirective', myDirective) ;
78-
}
74+
export default {
75+
install: app => {
76+
app.directive('myDirective', myDirective)
77+
}
7978
}
8079
```
8180

@@ -84,18 +83,18 @@ Please refer to [Vue2ToVue3](https://github.com/zdravkov/Vue2ToVue3) to see the
8483
```js
8584
// main.js
8685
import MyDirective from '@/directive'
87-
86+
8887
Vue.createApp(App).use(myDirective)
8988
```
9089

91-
- Transform `Global Configuration` by `window.app=app`
90+
- Transform `Global Configuration` by `window.app=app`
9291

93-
- Configure the global app instance in `main.js`
92+
- Configure the global app instance in `main.js`
9493

9594
```js
9695
// main.js
9796
const app = Vue.createApp(App)
98-
window.app = app // Configure the global app instance
97+
window.app = app // Configure the global app instance
9998
app.mount('#app')
10099
```
101100

@@ -131,17 +130,17 @@ Please refer to [Vue2ToVue3](https://github.com/zdravkov/Vue2ToVue3) to see the
131130

132131
Please refer to [Migration Guide from Vue.js team](https://vuejs.org/v2/guide/components-slots.html#Deprecated-Syntax) for more details.
133132

134-
`slot` attributes are deprecated since Vue 2.6.0. `v-slot` was introduced for named and scoped slots. In `vue-codemod` , the `slot-attribute` rule can transform `slot` attributes to `v-slot` syntax:
133+
`slot` attributes are deprecated since Vue 2.6.0. `v-slot` was introduced for named and scoped slots. In `vue-codemod` , the `slot-attribute` rule can transform `slot` attributes to `v-slot` syntax:
135134

136-
```vue
135+
```html
137136
<base-layout>
138137
<p slot="content">2.5 slot attribute in slot</p>
139138
</base-layout>
140139
```
141140

142-
will be transformed to:
141+
will be transformed to:
143142

144-
```vue
143+
```html
145144
<base-layout>
146145
<template v-slot:content>
147146
<p >2.5 slot attribute in slot</p>
@@ -151,14 +150,14 @@ will be transformed to:
151150

152151
For those named slots that use `v-if` and `v-else` together, `vue-codemod` will return an error.
153152

154-
```vue
153+
```html
155154
<el-button v-if="showCronBox" slot="append" @click="showBox = false"></el-button>
156155
<el-button v-else="showCronBox" slot="append" @click="showBox = true"></el-button>
157156
```
158157

159-
will be transformed to:
158+
will be transformed to:
160159

161-
```vue
160+
```html
162161
<template v-slot:append>
163162
<el-button v-if="showCronBox" @click="showBox = false"></el-button>
164163
</template>
@@ -167,16 +166,16 @@ will be transformed to:
167166
</template>
168167
```
169168

170-
Since `v-if` and `v-else` will be divided into two `<template>`, it will return an error:
169+
Since `v-if` and `v-else` will be divided into two `<template>`, it will return an error:
171170

172171
```powershell
173172
v-else used on element <el-button> without corresponding v-if.
174173
```
175174

176175
We need to manually put `v-if` and `v-else` into one `<template>` tag.
177176

178-
```vue
179-
<template v-slot:append>
177+
```html
178+
<template v-slot:append>
180179
<el-button v-if="showCronBox" @click="showBox = false"></el-button>
181180
<el-button v-else="showCronBox" slot="append" @click="showBox = true"></el-button>
182181
</template>
@@ -198,8 +197,8 @@ In Vue 3, `$on`, `$off` and `$once` instance methods are removed. Component inst
198197
199198
Please refer to [Migration Guide from Vue.js team](https://v3.vuejs.org/guide/migration/events-api.html) for more details.
200199
201-
- Add `mitt` dependencies
202-
200+
- Add `mitt` dependencies
201+
203202
```bash
204203
yarn add mitt
205204
// or
@@ -225,22 +224,22 @@ Please refer to [Migration Guide from Vue.js team](https://v3.vuejs.org/guide/mi
225224
```js
226225
// main.js
227226
import bus from '@/bus'
228-
227+
229228
const app = createApp(App).mount('#app')
230229
app.config.globalProperties.$bus = bus
231230
```
232231
233232
### /deep/
234233
235234
- `>>>` and `/deep/` are not supported
236-
- `/deep/ .el-input {}` should be transformed to `:deep(.el-input) {}`
235+
- `/deep/ .el-input {}` should be transformed to `:deep(.el-input) {}`
237236
- `v-deep:: .bar {}` should be transformed to `::v-deep(.bar) {}`
238237
239238
### Delimiter
240239
241240
In Vue 2, event internal statement can use `newline character` as the delimiter.
242241
243-
```vue
242+
```html
244243
<button @click="
245244
item.value = ''
246245
clearTag()
@@ -250,7 +249,7 @@ In Vue 2, event internal statement can use `newline character` as the delimiter.
250249
251250
But in Vue 3, `newline character` is no longer used as the delimiter. A `;` or `,` is needed.
252251
253-
```vue
252+
```html
254253
<button @click="
255254
item.value = '';
256255
clearTag()
@@ -339,7 +338,7 @@ const asyncRoutes = [
339338
340339
### All navigations in Router 4 are asynchronous
341340
342-
It may caused some render failure for components. For example, the following `RuleFilter.vue` component:
341+
It may caused some render failure for components. For example, the following `RuleFilter.vue` component:
343342
344343
```js
345344
watch: {
@@ -365,7 +364,7 @@ mounted() {
365364
}
366365
```
367366
368-
So you may need to wait for the router to be *ready* before trigger `filterSearch`:
367+
So you may need to wait for the router to be _ready_ before trigger `filterSearch`:
369368
370369
```js
371370
watch: {
@@ -379,43 +378,32 @@ watch: {
379378
this.$bus.$emit('filterSearch', param)
380379
})
381380
}
382-
383381
}
384382
}
385383
}
386384
```
387385
388386
## Element-ui
389387
390-
Currently, [Element UI](https://github.com/ElemeFE/element) provides a Vue3-supported libraries [Element Plus](https://github.com/element-plus/element-plus). The code related to `Element` needs to upgrade manuallly.
391-
392-
### Upgrade dependencies
393-
394-
```bash
395-
npm install element-plus
396-
npm remove element-ui
397-
```
398-
399-
### Import modules
388+
Currently, [Element UI](https://github.com/ElemeFE/element) provides a Vue3-supported libraries [Element Plus](https://github.com/element-plus/element-plus). `vue-codemod` has completed most of the upgrade scenarios such as dependency upgrade and dependency replacement, but `Element-Plus` is still in beta testing, some functions may be unstable, and developers need to upgrade manually.
400389
401-
> We are developing auto transformation for element-ui import.
390+
### Import CSS
402391
403-
- The import source has changed. Users can replace it globally in IDE: `import xx from 'element-ui'` -> `import xx from 'element-plus'`
404-
- Some components' name has changed. Users need to upgrade manually: `import { Message } from 'element-ui'` -> `import { ElMessage } from 'element-plus'`
392+
Part of global CSS should be imported from `element-plus`: `import('element-ui/lib/theme-chalk/index.css')` should be replaced with `import('element-plus/lib/theme-chalk/index.css')`
405393
406394
### `slot` attribute in el-table
407395
408-
Must use `<template>` to wrap the `slot`. For example:
396+
Must use `<template>` to wrap the `slot`. For example:
409397
410-
```vue
398+
```html
411399
<el-table>
412400
<span slot-scope='scope'>{{ scope.row.num }}</span>
413401
</el-table>
414402
```
415403
416404
Need to be transformed to:
417405
418-
```vue
406+
```html
419407
<el-table>
420408
<template #default='scope'>
421409
<span>{{ scope.row.num }}</span>

docs/typical-case.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Demo project address:[vue2-element-touzi-admin](https://github.com/originjs/vu
1111
## Global Install `vue-codemod`
1212

1313
```bash
14-
npm install originjs/vue-codemod -g`
14+
npm install originjs/vue-codemod -g`
1515
// or
1616
yarn add originjs/vue-codemod -g
1717
```
@@ -106,7 +106,7 @@ Processed 49 files
106106
79 places need to be transformed
107107
71 places was transformed
108108
The transformation rate is 89.87%
109-
The transformation stats:
109+
The transformation stats:
110110
111111
╔═══════════════════════════════════╤═══════╗
112112
║ Rule Names │ Count ║
@@ -198,7 +198,7 @@ index: 8
198198
199199
### Step 2:[Upgrade elment-ui to element-plus](https://github.com/originjs/vue2-element-touzi-admin/commit/8cddf35dcf04165fbf997e378205c5428dcb5e7f)
200200
201-
The biggest limitation of Vue 3 migration is the dependencies. If some components in your source code don't support Vue 3, we suggest your project remain unchanged until the Vue 3 supported version release.
201+
The biggest limitation of Vue 3 migration is the dependencies. If some components in your source code don't support Vue 3, we suggest your project remain unchanged until the Vue 3 supported version release.
202202
203203
### Step 3:[Fix errors or warnings from Global API](https://github.com/originjs/vue2-element-touzi-admin/commit/c1a7288299f80e23d5b1ad32f111ee10564ad8bd)
204204

0 commit comments

Comments
 (0)