vuex

Vuex Store Module access state

前提是你 提交于 2019-12-14 03:54:52
问题 I want to know how to access module store/state from another file. This is my code so far: /store/index.js import Vuex from 'vuex'; import categories from './modules/categories'; Vue.use(Vuex); const store = new Vuex.Store({ state: { }, actions: { }, mutations: { }, getters: { }, modules: { categories, }, }); export default store; /store/modules/categories.js const categories = { state: { categories: [ { name: 'category1' path: 'path/to/there' subcategories: [ { name: 'subcategory1' path:

Vue DOM not reactive to computed property

穿精又带淫゛_ 提交于 2019-12-14 03:54:03
问题 I have a button that is set to be disabled if a computed property's valid property is false. If true, the button should be enabled and allow a user to move to the next step in the current flow. My currentStep computed property is updating perfectly on changes to the current step's inputs, but the button :disabled="currentStep.valid" isn't recognizing the changes that ARE HAPPENING to currentStep.valid. If I click on the current component (addnewprogram) in vue-devtools to see it's data, the

Not able to access i18 plugin from mutation in classic mode store in Nuxt application

一世执手 提交于 2019-12-14 03:11:07
问题 I'm trying to implement Vuex i18n package within my Nuxt application. In my nuxt.conf.js file in plugins array I have: { src: '@/plugins/i18n.js', ssr: false }, plugins/i18n.js file is: import Vue from "vue"; import vuexI18n from "vuex-i18n/dist/vuex-i18n.umd.js"; import toEnglish from "../translations/toEnglish"; import toSpanish from "./../translations/toSpanish"; import toGerman from "./../translations/toGerman"; export default ({ store }) => { Vue.use( vuexI18n.plugin, store, {

Using kazupon/vue-i18n inside a state of Vuex

家住魔仙堡 提交于 2019-12-14 02:34:40
问题 Using https://github.com/kazupon/vue-i18n for localization Vue.t() || $t() || trans() receive a string which is a key to be translated by vue-i18n Hey guys! I'am trying the following code: import Vue from 'vue' export default { task: { status: [ { id: 'pending', name: Vue.t('pending') }, { id: 'done', name: 'Done' } ] } } That is my state.js which is the state of my VUEX! When I try to use the Vue.t function I have the following error: Uncaught TypeError: _vue2.default.t is not a function My

Array of objects - correct way of updating an object within the Vue.js ecosystem

纵饮孤独 提交于 2019-12-13 14:49:58
问题 I'm not sure exactly where the issue lies with this, but I'm going to see if anyone can help me understand what is going wrong with my code. I am utilising the Vuex store, to keep a track of some state that is constantly mutating. I'm doing this as follows: import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) export default new Vuex.Store({ state: { id: 0, contentBlocks: [] }, mutations: { addContentBlock(state, contentBlock) { contentBlock.id = state.id state.contentBlocks.push

What does { …obj1, obj2 } do exactly [duplicate]

心已入冬 提交于 2019-12-13 12:43:01
问题 This question already has answers here : What do these three dots in React do? (22 answers) Closed 8 months ago . Let's say we have two objects: const state = { fishes: { /* some obj data */ }, animals: { /* some obj data */ } const animals = { /* some NEW data */ } In Vuex there is a method replaceState(), which according to the documentation takes one argument and replaces the state with that object. What will be the result of the following: replaceState({ ...state, animals }) More

Filter array based on multiple options (Vue/JavaScript)

Deadly 提交于 2019-12-13 06:26:27
问题 If this is a duplicate post I apologize. I searched a couple different things before posting this. I'm trying to figure out how to filter results based off of two options. I can get one of the options to work but need both to drive the results. I have 4 computed properties: filteredResults: where the filtering is taking place phases: collection of all the phases based on the results results: original results list (stored in Vuex) states: collection of all the states based on the results In

vuejs2: How to pass vuex store to vue-router components

萝らか妹 提交于 2019-12-13 05:25:52
问题 In case when vue-router is not used, store can be passed to child components when declaring new Vue() But I am using both vue-router and vuex . In this case how can I make store available to components . For e.g. my store.js is typical: import Vue from 'vue' import Vuex from 'vuex' import jwt_decode from 'jwt-decode' import axios from 'axios' import VueAxios from 'vue-axios' Vue.use(Vuex); Vue.use(VueAxios, axios); export const store = new Vuex.Store({ state: { jwt: localStorage.getItem('t'),

How can I pass input file with vue.js 2?

只谈情不闲聊 提交于 2019-12-13 03:46:34
问题 My vue component like this : <template> <div class="modal" tabindex="-1" role="dialog"> ... <div class="form-group"> <label for="change-image">Change image</label> <input type="file" name="replace" v-on:change="changeImage"> </div> <div class="form-group"> <label for="alt-image">Alt attr</label> <input type="text" class="form-control" v-model="altImage"> </div> <div class="checkbox"> <label> <input type="checkbox" v-model="mainCover"> Set Cover </label> </div> <button type="button" class="btn

Styling not being applied to SINGLE ELEMENT after exacting JQuery function on single element within a ,vue page

情到浓时终转凉″ 提交于 2019-12-13 03:38:37
问题 I'm using JQuery-AsRange (https://github.com/thecreation/jquery-asRange) within my vue.js project. The function execute within the .vue page within the script section of my vue page and the JQuery-AsRange library works perfect but, lack any css styling. The css style that is loaded should handle those id and tags that are generated (I can copy can paste the generated non-style JavaScript code and add hardcore it into the template and it will be styled correctly- it just won't move), but when