Skip to content

Commit 7e6598c

Browse files
committed
docs: update readme
1 parent 2a2629e commit 7e6598c

File tree

1 file changed

+38
-51
lines changed

1 file changed

+38
-51
lines changed

README.md

Lines changed: 38 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,19 @@
1-
# Vue Composition API
1+
# @vue/composition-api
22

3-
Vue 2 plugin for **Composition API** in Vue 3.
3+
Vue 2 plugin for **Composition API**
44

55
[![npm](https://img.shields.io/npm/v/@vue/composition-api)](https://www.npmjs.com/package/@vue/composition-api)
66
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/vuejs/composition-api/Build%20&%20Test)](https://github.com/vuejs/composition-api/actions?query=workflow%3A%22Build+%26+Test%22)
77

8-
English | [**中文文档**](./README.zh-CN.md) / [**Composition API RFC**](https://composition-api.vuejs.org/)
8+
English | [中文](./README.zh-CN.md) · [**Composition API Docs**](https://composition-api.vuejs.org/)
99

10+
</p>
1011

11-
**Note: the primary goal of this package is to allow the community to experiment with the API and provide feedback before it's finalized. The implementation may contain minor inconsistencies with the RFC as the latter gets updated. We do not recommend using this package for production yet at this stage.**
12-
13-
---
14-
15-
# Navigation
16-
17-
- [Installation](#Installation)
18-
- [Usage](#Usage)
19-
- [TypeScript](#TypeScript)
20-
- [TSX](#tsx)
21-
- [Limitations](#Limitations)
22-
- [Changelog](https://github.com/vuejs/composition-api/blob/master/CHANGELOG.md)
23-
24-
# Installation
25-
26-
**npm**
12+
## Installation
2713

2814
```bash
2915
npm install @vue/composition-api
30-
```
31-
32-
**yarn**
33-
34-
```bash
16+
# or
3517
yarn add @vue/composition-api
3618
```
3719

@@ -41,9 +23,9 @@ yarn add @vue/composition-api
4123
<script src="https://unpkg.com/@vue/composition-api/dist/vue-composition-api.umd.js"></script>
4224
```
4325

44-
By using the global variable `window.vueCompositionApi`
26+
The package will be exposed to global variable `window.vueCompositionApi`
4527

46-
# Usage
28+
## Usage
4729

4830
You must install `@vue/composition-api` via `Vue.use()` before using other APIs:
4931

@@ -54,28 +36,28 @@ import VueCompositionApi from '@vue/composition-api';
5436
Vue.use(VueCompositionApi);
5537
```
5638

57-
After installing the plugin you can use the [Composition API](https://vue-composition-api-rfc.netlify.com/) to compose your component.
39+
After installing the plugin you can use the [Composition API](https://composition-api.vuejs.org/) to compose your component.
5840

59-
# TypeScript
41+
## TypeScript Support
6042

61-
**This plugin requires TypeScript version >3.5.1. If you are using vetur, make sure to set `vetur.useWorkspaceDependencies` to `true`.**
43+
> TypeScript version **>3.5.1** is required
6244
6345
To let TypeScript properly infer types inside Vue component options, you need to define components with `defineComponent`:
6446

6547
```ts
6648
import { defineComponent } from '@vue/composition-api';
6749

68-
const Component = defineComponent({
50+
const ComponentA = defineComponent({
6951
// type inference enabled
70-
});
52+
})
7153

72-
const Component = {
54+
const ComponentB = {
7355
// this will NOT have type inference,
7456
// because TypeScript can't tell this is options for a Vue component.
75-
};
57+
}
7658
```
7759

78-
## TSX
60+
### TSX
7961

8062
:rocket: An Example [Repository](https://github.com/liximomo/vue-composition-api-tsx-example) with TS and TSX support is provided to help you start.
8163

@@ -102,13 +84,23 @@ declare global {
10284
}
10385
```
10486

105-
# Limitations
87+
## Limitations
88+
89+
> :white_check_mark:
90+
> Support &nbsp;&nbsp;&nbsp;&nbsp;:x: Not Supported
91+
92+
### Performance Impact
93+
94+
Due the the limitation of Vue2's public API. `@vue/composition-api` inevitably introduced some extract costs. This should not concern you in most of the cases.
10695

107-
## `Ref` Unwrap
96+
You can check the [benchmarks](https://antfu.github.io/vue-composition-api-benchmark-results/) that comparing with Vue 2's option API and vue-next.
10897

109-
`Unwrap` is not working with Array index.
11098

111-
### **Should not** store `ref` as a **direct** child of `Array`:
99+
### `Ref` Unwrap
100+
101+
:x: `Unwrap` is not working with Array index.
102+
103+
#### **Should NOT** store `ref` as a **direct** child of `Array`:
112104

113105
```js
114106
const state = reactive({
@@ -122,7 +114,7 @@ state.list.push(ref(1));
122114
state.list[1].value === 1; // true
123115
```
124116

125-
### **Should not** use `ref` in a plain object when working with `Array`:
117+
#### **Should NOT** use `ref` in a plain object when working with `Array`:
126118

127119
```js
128120
const a = {
@@ -149,7 +141,7 @@ const b = reactive({
149141
b.list[0].count.value === 0; // true
150142
```
151143

152-
### **Should** always use `ref` in a `reactive` when working with `Array`:
144+
#### **Should** always use `ref` in a `reactive` when working with `Array`:
153145

154146
```js
155147
const a = reactive({
@@ -170,23 +162,18 @@ b.list.push(
170162
b.list[1].count === 1; // true
171163
```
172164

173-
### ***Using*** `reactive` will mutate the origin object
174-
175-
This is an limitation of using `Vue.observable` in Vue 2.
176-
> Vue 3 will return an new proxy object.
165+
### :warning: `reactive` ***mutates*** the original object
177166

178-
---
167+
`reactive` uses `Vue.observable` underneath which will ***mutate*** the original object.
179168

180-
## `watch()` API
169+
> :bulb: Vue 3 will return an new proxy object.
181170
182-
`onTrack` and `onTrigger` are not available in `WatchOptions`.
183171

184-
---
172+
### `watch()` API
185173

186-
## Template Refs
174+
:x: `onTrack` and `onTrigger` are not available in `WatchOptions`.
187175

188-
> :white_check_mark:
189-
> Support &nbsp;&nbsp;&nbsp;&nbsp;:x: Not Supported
176+
### Template Refs
190177

191178
:white_check_mark:
192179
String ref && return it from `setup()`:

0 commit comments

Comments
 (0)