vuex

Why the value of input file missing when I input the another input on the vue component?

不羁岁月 提交于 2019-12-24 01:44:07
问题 I have two component My first component (parent component) like this : <template> <div> ... <form-input id="name" name="name" v-model="name">Name</form-input> <form-input id="birth-date" name="birth_date" type="date" v-model="birthDate">Date of Birth</form-input> <form-input id="avatar" name="avatar" type="file" v-on:triggerChange="onFileChange($event)">Avatar</form-input> <form-input id="mobile-number" name="mobile_number" type="number" v-model="mobileNumber">Mobile Number</form-input> ... <

NativeScript vue, vuex and urlhandler

自古美人都是妖i 提交于 2019-12-23 23:43:24
问题 Edit I'm using https://github.com/hypery2k/nativescript-urlhandler to open a deep link within my app - using NativeScript vue, and vuex. It seems that in order to get at the methods needed to do routing [ $navigateTo etc] this plugin needs to be set up slightly differently from the examples given in docs. import Vue from "nativescript-vue"; import Vuex from "vuex"; Vue.use(Vuex); import { handleOpenURL } from 'nativescript-urlhandler'; new Vue({ mounted() { handleOpenURL( (appURL) => {

mpvue的toast弹窗组件-mptosat

时光怂恿深爱的人放手 提交于 2019-12-23 21:46:23
  几乎每个小程序都会用到的弹窗功能,弹窗是为了友好的提示用户目前小程序的状态。这样以来toast弹窗就成了小程序不可或缺的组件。mptosat用过,不赖的一款。下面记录以下使用方法: 介绍 mptoast 是一个基于mpvue的简单弹窗组件 github地址: https://github.com/noahlam/mpvue-toast 安装 1.安装 vuex ,如果你项目还没使用的话。请放心,虽然 mptoast 依赖 vuex ,你不会接触到任何有关 vuex 的代码。添加 vuex 只为让你写更少的代码。 npm i vuex 2.安装 mptoast npm i mptoast -D 3.在项目的主配置文件 (一般位于src/main.js) 加入以下代码 import mpvueToastRegistry from 'mptoast' mpvueToastRegistry(Vue) 4.在你需要弹窗的页面,引入组件,并注册,然后在页面内加入一个你注册的组件,就可以在js里面调用 this.$mptoast() 了, 以下是一个简单的实例 <template> <div> <-- 省略其他代码 --> <mptoast /> </div> </template> <script> import mptoast from 'mptoast' export default

How can I prevent Vuex from interfering with my class instance?

谁都会走 提交于 2019-12-23 20:40:53
问题 I am trying to store an instance of a class in Vuex (the EditorState from ProseMirror). This class is more or less immutable from the outside, meaning that whenever I want to make changes to it, I will just put a new instance of the class into Vuex. As such, I do not need Vue's change tracking here, and in fact it actually seems to interfere with the internal workings of ProseMirror, so I was wondering if there was a way that I could isolate my object from Vue so that it is treated atomically

Error: [vuex] expects string as the type, but found undefined

狂风中的少年 提交于 2019-12-23 17:17:06
问题 Studying Vuex. I wrote a simple login page against the example project and the document, but when I tried to use a action function, the developer tool just warned me Here is my code: src/views/Login.vue handleLogin (formName) { this.$refs[formName].validate(valid => { if (valid) { // to do this.$store.dispatch('user/login', this.loginUser) } else { ...... }) } }) src/store/index.js import Vue from 'vue' import Vuex from 'vuex' import user from './modules/User/user' // import info from '.

Vuex store type with Typescript

陌路散爱 提交于 2019-12-23 07:45:50
问题 I'm trying to get a Vuex store to be Typescript friendly. I'm building the store as explained here. However, when I access this.$store from a component, the type is Store<any> . I couldn't figure out how to change it so that it defaults to Store<MyState> without requiring a cast every time. 回答1: Unfortunately it is impossible to override the Store<any> type that is defined by the VueX types with a more specific type. The best I could come up with was to add a second field that returns $store

Vuex store type with Typescript

寵の児 提交于 2019-12-23 07:45:38
问题 I'm trying to get a Vuex store to be Typescript friendly. I'm building the store as explained here. However, when I access this.$store from a component, the type is Store<any> . I couldn't figure out how to change it so that it defaults to Store<MyState> without requiring a cast every time. 回答1: Unfortunately it is impossible to override the Store<any> type that is defined by the VueX types with a more specific type. The best I could come up with was to add a second field that returns $store

Correct way to cache data in vuex

亡梦爱人 提交于 2019-12-23 02:34:33
问题 I am trying to asynchronously load data into vuex that is static but is used by multiple routes.I only want to fetch the data once and only when a route that needs it is visited. This is what I'm currently doing but I'm not sure if this is the correct convention or if there is a better/more Vueish way. // store.js export default new Vuex.Store({ state: { _myData: null, }, getters: { myData: (state) => new Promise((resolve,reject) => { if(state._myData){ resolve(state._myData); } else { axios

Nuxt+Vuex初体验

我只是一个虾纸丫 提交于 2019-12-22 20:54:52
小呀嘛小二郎,背着书包上学堂。。。 今天一个困扰了我一周时间的问题终于被我解决了,值得庆祝 在Nuxt中使用Vuex实现数据存储 首先: 在store目录下新建一个index.js文件 需要有两个组件(index || demo)[组件名自定] 一、在store目录下新建一个index.js文件 index.js内容如下 //定义数据 export const state = () => ({ count: 1 //定义count初始值为1 }) //定义方法 export const mutations = { inc (state) { state.count++ }, deinc(state){ state.count-- } } 二、需要有两个组件 index.vue内容如下: <template> <div> <h1>{{ count }}</h1> <!--count是计算属性中的count--> <button @click="inc">增加</button> <NuxtLink to="/demo">Demo</NuxtLink> </div> </template> <script> //使用解构赋值从vuex中引入需要的state,也可以引入mapMutations... import { mapState } from "vuex"; export

Vue2 + Vuex Commit Not Committing (without Vue devtools)

荒凉一梦 提交于 2019-12-22 19:01:53
问题 I'm trying to accomplish what should be a basic task with Vuex, but for some reason it's not working, and after searching far and wide, I greatly appreciate any help. What I'm trying to do : Update a list (object) of objects in my store with a new property (object). What's going wrong : Before I even dispatch the action to commit the new object from my component (I'm accessing the action via mapActions), certain properties in any existing objects in the list are updated with the values tied