mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-04-27 07:09:16 -05:00
docs(zh): in build-targets.md add "using vuex" (#5883) [skip ci]
This commit is contained in:
@@ -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',
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user