-
Notifications
You must be signed in to change notification settings - Fork 533
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,3 +46,4 @@ | |
|
||
* issues 需求 | ||
* [request](request.md) | ||
* [页面通讯](vuex.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# vuex | ||
vuex | ||
|
||
## 页面通信 | ||
该示例为小程序间的页面通讯,利用 vuex 实现 | ||
|
||
在 `mpvue`框架中使用 `vuex` 与在 `vue` 中使用是一样的体验, | ||
|
||
1.建立相关的目录结构 | ||
|
||
 | ||
|
||
2.在 src/main.js 中将 store 挂载到 vue 原型下面 | ||
|
||
``` javascript | ||
Vue.prototype.$store = store; | ||
``` | ||
|
||
3.在页面中通过 mapGetters 和 mapMutations 使用 state | ||
|
||
``` javascript | ||
methods: { | ||
...mapMutations({ | ||
setMpvueInfoVuex: 'SET_MPVUEINFO' | ||
}) | ||
}, | ||
|
||
computed: { | ||
...mapGetters([ | ||
'mpvueInfo' | ||
]) | ||
} | ||
``` | ||
|
||
**效果** | ||
|
||
 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters