File tree 4 files changed +47
-15
lines changed
4 files changed +47
-15
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ npm install @vue/composition-api
17
17
yarn add @vue/composition-api
18
18
```
19
19
20
- You must install ` @vue/composition-api ` via ` Vue.use() ` before you can use the [ Composition API] ( https://composition-api.vuejs.org/ ) to compose your component.
20
+ You must install ` @vue/composition-api ` as a plugin via ` Vue.use() ` before you can use the [ Composition API] ( https://composition-api.vuejs.org/ ) to compose your component.
21
21
22
22
``` js
23
23
import Vue from ' vue'
@@ -27,17 +27,24 @@ Vue.use(VueCompositionApi)
27
27
```
28
28
29
29
``` js
30
- // in components
30
+ // use the APIs
31
31
import { ref , reactive } from ' @vue/composition-api'
32
32
```
33
33
34
+ > :bulb : When you migrate to Vue 3, just replacing ` @vue/composition-api ` to ` vue ` and your code should just work.
35
+
34
36
### CDN
35
37
38
+ Add the following lines in your ` <head> ` to import Vue and ` @vue/composition-api ` .
39
+
40
+ <!-- cdn-links-start-->
36
41
``` html
37
- <script src =" https://unpkg.com/@vue/composition-api/dist/vue-composition-api.umd.js" ></script >
42
+ <
script src =
" https://cdn.jsdelivr.net/npm/[email protected] " ></
script >
43
+ <
script src =
" https://cdn.jsdelivr.net/npm/@vue/[email protected] " ></
script >
38
44
```
45
+ <!-- cdn-links-end-->
39
46
40
- The package will be exposed to global variable ` window.vueCompositionApi `
47
+ ` @vue/composition-api ` will be exposed to global variable ` window.vueCompositionApi ` and you have to install it before using the APIs.
41
48
42
49
``` js
43
50
// install the plugin
Original file line number Diff line number Diff line change @@ -11,15 +11,6 @@ Vue 2 插件用于提供 Vue 3 中的 **组合式 API**.
11
11
12
12
---
13
13
14
- # 导航
15
-
16
- - [ 安装] ( #安装 )
17
- - [ 使用] ( #使用 )
18
- - [ TypeScript] ( #TypeScript )
19
- - [ TSX] ( #tsx )
20
- - [ 限制] ( #限制 )
21
- - [ 更新日志] ( https://github.com/vuejs/composition-api/blob/master/CHANGELOG.md )
22
-
23
14
# 安装
24
15
25
16
** npm**
@@ -36,9 +27,12 @@ yarn add @vue/composition-api
36
27
37
28
** CDN**
38
29
30
+ <!-- cdn-links-start-->
39
31
``` html
40
- <script src =" https://unpkg.com/@vue/composition-api/dist/vue-composition-api.umd.js" ></script >
32
+ <
script src =
" https://cdn.jsdelivr.net/npm/[email protected] " ></
script >
33
+ <
script src =
" https://cdn.jsdelivr.net/npm/@vue/[email protected] " ></
script >
41
34
```
35
+ <!-- cdn-links-end-->
42
36
43
37
通过全局变量 ` window.vueCompositionApi ` 来使用。
44
38
Original file line number Diff line number Diff line change 13
13
},
14
14
"main" : " dist/vue-composition-api.js" ,
15
15
"umd:main" : " dist/vue-composition-api.umd.js" ,
16
+ "browser" : " dist/vue-composition-api.umd.js" ,
16
17
"module" : " dist/vue-composition-api.module.js" ,
17
18
"typings" : " dist/index.d.ts" ,
18
19
"author" : {
31
32
"test" : " yarn test-dts && yarn test-unit" ,
32
33
"test-unit" : " cross-env NODE_ENV=test jest" ,
33
34
"test-dts" : " tsc -p ./test-dts/tsconfig.json && yarn build && tsc -p ./test-dts/tsconfig.build.json" ,
35
+ "update-readme" : " node ./scripts/update-readme.js" ,
34
36
"changelog" : " conventional-changelog -p angular -i CHANGELOG.md -s" ,
35
37
"prepublish" : " yarn test" ,
36
38
"postpublish" : " yarn release-gh" ,
37
- "version" : " yarn changelog && git add CHANGELOG.md" ,
39
+ "version" : " yarn changelog && yarn update-readme && git add CHANGELOG.md README.* " ,
38
40
"release" : " yarn version && git push --follow-tags && yarn publish --non-interactive" ,
39
41
"release-gh" : " conventional-github-releaser -p angular"
40
42
},
Original file line number Diff line number Diff line change
1
+ const { promises : fs } = require ( 'fs' )
2
+ const path = require ( 'path' )
3
+ const { version } = require ( '../package.json' )
4
+
5
+ const files = [ '../README.md' , '../README.zh-CN.md' ]
6
+
7
+ const MakeLinks = ( version , vueVersion = '2.6' ) =>
8
+ `
9
+ \`\`\`html
10
+ <script src="https://cdn.jsdelivr.net/npm/vue@${ vueVersion } "></script>
11
+ <script src="https://cdn.jsdelivr.net/npm/@vue/composition-api@${ version } "></script>
12
+ \`\`\`
13
+ `
14
+
15
+ ; ( async ( ) => {
16
+ const links = MakeLinks ( version )
17
+
18
+ for ( const file of files ) {
19
+ const filepath = path . resolve ( __dirname , file )
20
+ const raw = await fs . readFile ( filepath , 'utf-8' )
21
+
22
+ const updated = raw . replace (
23
+ / < ! - - c d n - l i n k s - s t a r t - - > ( [ \s \S ] * ) < ! - - c d n - l i n k s - e n d - - > / g,
24
+ `<!--cdn-links-start-->${ links } <!--cdn-links-end-->`
25
+ )
26
+
27
+ await fs . writeFile ( filepath , updated , 'utf-8' )
28
+ }
29
+ } ) ( )
You can’t perform that action at this time.
0 commit comments