vuex

Vuex store.watch only accepts a function in Vue router guard

此生再无相见时 提交于 2021-02-17 06:05:30
问题 I am trying to watch and wait until Vue router guard will get final value from Vuex however it throws [vuex] store.watch only accepts a function Here is the code: const isAdmin = _.get(store, 'getters.user/isAdmin', undefined) if (to.matched.some(record => record.meta.isAdmin)) { if (isAdmin === undefined) { const watcher = store.watch(isAdmin, isAdmin => { watcher() // stop watching if (!isAdmin) next({ path: '/not-available' }) }) } else if (serv.isAuth() && !isAdmin) { next({ path: '/not

Vuex store.watch only accepts a function in Vue router guard

我只是一个虾纸丫 提交于 2021-02-17 06:05:23
问题 I am trying to watch and wait until Vue router guard will get final value from Vuex however it throws [vuex] store.watch only accepts a function Here is the code: const isAdmin = _.get(store, 'getters.user/isAdmin', undefined) if (to.matched.some(record => record.meta.isAdmin)) { if (isAdmin === undefined) { const watcher = store.watch(isAdmin, isAdmin => { watcher() // stop watching if (!isAdmin) next({ path: '/not-available' }) }) } else if (serv.isAuth() && !isAdmin) { next({ path: '/not

Vuex持久化插件-解决刷新数据消失的问题(vuex-persistedstate)

南笙酒味 提交于 2021-02-17 05:38:14
Vuex持久化插件-解决刷新数据消失的问题(vuex-persistedstate) 参考文章: (1)Vuex持久化插件-解决刷新数据消失的问题(vuex-persistedstate) (2)https://www.cnblogs.com/yangxuan/p/11064895.html 备忘一下。 来源: oschina 链接: https://my.oschina.net/u/4428122/blog/4953274

vue组件间传参

前提是你 提交于 2021-02-11 20:39:03
1. 浏览器传参 设置 sessionStorage.setItem('参数名','参数值'); 获取 sessionStorage.getItem('参数名') 2. 父子组件传参 父组件 <h2 title="参数值">父组件传参</h2> 子组件 export default { props: { title: { type: String, default: 'hello world' } } } 3. vuex export default new Vuex.Store({ state: { transferArgument:'兄弟间传参', gettersStr: '' }, getters: { // 过滤state中的值 changeState(state) { state.gettersStr = '修改了state中参数'; }, }, mutations: { setTransferArgument(state,a) { state.transferArgument = '修改state中参数:' + a; } }, actions: { //触发mutations中的方法,异步操作 actionsSet(context, a) { context.commit('setTransferArgument', a) } }, modules: { } })

Vue how to get value from sub component

时间秒杀一切 提交于 2021-02-11 17:23:56
问题 Here is my use case: My main page have several sub-components that collect different input from user, finally I want to submit the whole page with all inputs collected. Therefore I want to retrieve the data from sub-component One option is to use store , but my sub-components are super simple, just some forms, store seems too heavy... Another option is that I can modify prop , although I know this is bad practice, but this approach looks just perfect.... Is it ok to modify prop if my logic is

Vue how to get value from sub component

佐手、 提交于 2021-02-11 17:22:14
问题 Here is my use case: My main page have several sub-components that collect different input from user, finally I want to submit the whole page with all inputs collected. Therefore I want to retrieve the data from sub-component One option is to use store , but my sub-components are super simple, just some forms, store seems too heavy... Another option is that I can modify prop , although I know this is bad practice, but this approach looks just perfect.... Is it ok to modify prop if my logic is

How to activate / deactivate an Electron.js submenu from inside a Vue.js Component according to a specific Vuex state?

拥有回忆 提交于 2021-02-11 14:14:51
问题 I can't find the solution to this anywhere. I have this sample vue-vuex-electron app that I've created and I want to enable / disable some submenus of the app according to whether the vuex state 'isLogged' is true or false. I managed to apply that to the nav router-links (using v-if), but not yet to the menu items... 'cause I don't know how to access the actual Menu (already set and rendered at the main process). For example, at my Home.vue, I'd like to import the Electron.Menu of the app and

Store referenced but not defined

为君一笑 提交于 2021-02-11 13:14:36
问题 Hey I have some bullshit issue with store not being defined. Any advice so I can move on and finish this software build? Store and contents of store appears in Vue Inspector tools. When put inline like below it breaks and renders blank - no DOM content inside App component. App.vue offending excerpt <div v-if="$store.state.showPreloader == true" id="preloaderWrap"> <div id="preloader"></div> </div> Store.js import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) const state = { stuff }

Store referenced but not defined

南楼画角 提交于 2021-02-11 13:10:34
问题 Hey I have some bullshit issue with store not being defined. Any advice so I can move on and finish this software build? Store and contents of store appears in Vue Inspector tools. When put inline like below it breaks and renders blank - no DOM content inside App component. App.vue offending excerpt <div v-if="$store.state.showPreloader == true" id="preloaderWrap"> <div id="preloader"></div> </div> Store.js import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) const state = { stuff }

Access data from another Component

谁说我不能喝 提交于 2021-02-11 08:27:49
问题 now i have 2 Components 1 - is just a drop down list v-select <v-row align="center" > <v-col class="d-flex" cols="12" sm="6" v-if="Compounds" > <v-select :items="Compounds" v-model="selectedItems" label="Select" item-value="id" item-text="name" v-on:change="selectedCompound"> </v-select> {{ selectedItems }} </v-col> </v-row> with method methods: { selectedCompound(h2o) { console.log(h2o); console.log("This is from Selected Compound"); }, and i call it in another page <div> <SelectCompound><