Skip to content

Commit

Permalink
docs: add link and mention about vuex 4
Browse files Browse the repository at this point in the history
  • Loading branch information
kiaking committed Nov 18, 2020
1 parent ac6041a commit e9ac8c3
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 52 deletions.
56 changes: 49 additions & 7 deletions docs/.vuepress/config.js
Expand Up @@ -59,7 +59,13 @@ module.exports = {
nav: [
{ text: 'Guide', link: '/guide/' },
{ text: 'API Reference', link: '/api/' },
{ text: 'Release Notes', link: 'https://github.com/vuejs/vuex/releases' }
{ text: 'Release Notes', link: 'https://github.com/vuejs/vuex/releases' },
{
text: 'v3.x',
items: [
{ text: 'v4.x', link: 'https://next.vuex.vuejs.org/' }
]
}
],
sidebar: [
{
Expand Down Expand Up @@ -103,7 +109,13 @@ module.exports = {
nav: [
{ text: '指南', link: '/zh/guide/' },
{ text: 'API 参考', link: '/zh/api/' },
{ text: '更新记录', link: 'https://github.com/vuejs/vuex/releases' }
{ text: '更新记录', link: 'https://github.com/vuejs/vuex/releases' },
{
text: 'v3.x',
items: [
{ text: 'v4.x', link: 'https://next.vuex.vuejs.org/' }
]
}
],
sidebar: [
{
Expand Down Expand Up @@ -147,7 +159,13 @@ module.exports = {
nav: [
{ text: 'ガイド', link: '/ja/guide/' },
{ text: 'API リファレンス', link: '/ja/api/' },
{ text: 'リリースノート', link: 'https://github.com/vuejs/vuex/releases' }
{ text: 'リリースノート', link: 'https://github.com/vuejs/vuex/releases' },
{
text: 'v3.x',
items: [
{ text: 'v4.x', link: 'https://next.vuex.vuejs.org/' }
]
}
],
sidebar: [
{
Expand Down Expand Up @@ -191,7 +209,13 @@ module.exports = {
nav: [
{ text: 'Руководство', link: '/ru/guide/' },
{ text: 'Справочник API', link: '/ru/api/' },
{ text: 'История изменений', link: 'https://github.com/vuejs/vuex/releases' }
{ text: 'История изменений', link: 'https://github.com/vuejs/vuex/releases' },
{
text: 'v3.x',
items: [
{ text: 'v4.x', link: 'https://next.vuex.vuejs.org/' }
]
}
],
sidebar: [
{
Expand Down Expand Up @@ -235,7 +259,13 @@ module.exports = {
nav: [
{ text: '가이드', link: '/kr/guide/' },
{ text: 'API 레퍼런스', link: '/kr/api/' },
{ text: '릴리즈 노트', link: 'https://github.com/vuejs/vuex/releases' }
{ text: '릴리즈 노트', link: 'https://github.com/vuejs/vuex/releases' },
{
text: 'v3.x',
items: [
{ text: 'v4.x', link: 'https://next.vuex.vuejs.org/' }
]
}
],
sidebar: [
{
Expand Down Expand Up @@ -279,7 +309,13 @@ module.exports = {
nav: [
{ text: 'Guia', link: '/ptbr/guide/' },
{ text: 'Referência da API', link: '/ptbr/api/' },
{ text: 'Notas da Versão', link: 'https://github.com/vuejs/vuex/releases' }
{ text: 'Notas da Versão', link: 'https://github.com/vuejs/vuex/releases' },
{
text: 'v3.x',
items: [
{ text: 'v4.x', link: 'https://next.vuex.vuejs.org/' }
]
}
],
sidebar: [
{
Expand Down Expand Up @@ -323,7 +359,13 @@ module.exports = {
nav: [
{ text: 'Guide', link: '/fr/guide/' },
{ text: 'API', link: '/fr/api/' },
{ text: 'Notes de version', link: 'https://github.com/vuejs/vuex/releases' }
{ text: 'Notes de version', link: 'https://github.com/vuejs/vuex/releases' },
{
text: 'v3.x',
items: [
{ text: 'v4.x', link: 'https://next.vuex.vuejs.org/' }
]
}
],
sidebar: [
{
Expand Down
4 changes: 4 additions & 0 deletions docs/README.md
@@ -1,5 +1,9 @@
# What is Vuex?

::: tip NOTE
This is the docs for Vuex 3, which works with Vue 2. If you're looking for docs for Vuex 4, which works with Vue 3, [please check it out here](https://next.vuex.vuejs.org/).
:::

<VideoPreview />

Vuex is a **state management pattern + library** for Vue.js applications. It serves as a centralized store for all the components in an application, with rules ensuring that the state can only be mutated in a predictable fashion. It also integrates with Vue's official [devtools extension](https://github.com/vuejs/vue-devtools) to provide advanced features such as zero-config time-travel debugging and state snapshot export / import.
Expand Down
25 changes: 0 additions & 25 deletions docs/guide/README.md
Expand Up @@ -16,8 +16,6 @@ We will be using ES2015 syntax for code examples for the rest of the docs. If yo

After [installing](../installation.md) Vuex, let's create a store. It is pretty straightforward - just provide an initial state object, and some mutations:

### Vuex 3.x (for Vue 2)

```js
import Vue from 'vue'
import Vuex from 'vuex'
Expand All @@ -36,29 +34,6 @@ const store = new Vuex.Store({
})
```

### Vuex 4.x (for Vue 3)

```js
import { createStore } from 'vuex'
import { createApp } from 'vue'

const store = createStore({
state () {
return {
count: 1
}
},
mutations: {
increment (state) {
state.count++
}
}
})

const app = createApp({ /* your root component */ })
app.use(store)
```

Now, you can access the state object as `store.state`, and trigger a state change with the `store.commit` method:

```js
Expand Down
20 changes: 0 additions & 20 deletions docs/installation.md
Expand Up @@ -19,43 +19,23 @@ Include `vuex` after Vue and it will install itself automatically:

```bash
npm install vuex --save

# If using Vue 3.0 + Vuex 4.0:
npm install vuex@next --save
```

## Yarn

```bash
yarn add vuex

# If using Vue 3.0 + Vuex 4.0:
yarn add vuex@next --save
```

When used with a module system, you must explicitly install Vuex as a plugin:

### With Vue 2

```js
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
```

### With Vue 3

```js
import { createApp } from 'vue'
import { createStore } from 'vuex'

const app = createApp({ ... })
const store = createStore({ ... })

app.use(store)
```

You don't need to do this when using global script tags.

## Promise
Expand Down

0 comments on commit e9ac8c3

Please sign in to comment.