Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In build-targets.md add "using vuex" #5883

Merged
merged 2 commits into from
Sep 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/zh/guide/build-targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,20 @@ dist/foo.1.js 5.24 kb 1.64 kb
<!-- foo-one 的实现的 chunk 会在用到的时候自动获取 -->
<foo-one></foo-one>
```

## 在构建时使用 vuex
在构建 [Web Components 组件](#web-components-组件)或[库](#库)时,入口点不是 `main.js` ,而是 `entry-wc.js` 文件,该文件由此生成: https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/lib/commands/build/resolveWcEntry.js

因此,要在 Web Components 组件的目标中使用 vuex ,你需要在 `App.vue` 中初始化存储 (store):
``` js
import store from './store'

// ...

export default {
store,
name: 'App',
// ...
}
```