Axios can’t set data

In option functions like data and created, vue binds this to the view-model instance for us, so we can use this.contas, but in the function inside then, this is not bound. So you need to preserve the view-model like (created means the component’s data structure is assembled, which is enough here, mounted will delay the … Read more

How to make a dynamic import in Nuxt?

Since the error was thrown during the import statement, I’d recommended using dynamic imports as explained in my other answer here. async mounted() { if (process.client) { const Ace = await import(‘ace-builds/src-noconflict/ace’) Ace.edit… } }, From the official documentation: https://nuxtjs.org/docs/2.x/internals-glossary/context EDIT: I’m not sure about Ace and it’s maybe a drastic change but you may … Read more

Vuex – Do not mutate vuex store state outside mutation handlers

It could be a bit tricky to use v-model on a piece of state that belongs to Vuex. and you have used v-model on todo.text here: <input class=”edit” type=”text” v-model=”todo.text” v-todo-focus=”todo == editedTodo” @blur=”doneEdit(todo)” @keyup.enter=”doneEdit(todo)” @keyup.esc=”cancelEdit(todo)”> use :value to read value and v-on:input or v-on:change to execute a method that perform the mutation inside an … Read more

How to implement debounce in Vue2?

I am using debounce NPM package and implemented like this: <input @input=”debounceInput”> methods: { debounceInput: debounce(function (e) { this.$store.dispatch(‘updateInput’, e.target.value) }, config.debouncers.default) } Using lodash and the example in the question, the implementation looks like this: <input v-on:input=”debounceInput”> methods: { debounceInput: _.debounce(function (e) { this.filterKey = e.target.value; }, 500) }

How to import and use image in a Vue single file component?

As simple as: <template> <div id=”app”> <img src=”./assets/logo.png”> </div> </template> <script> export default { } </script> <style lang=”css”> </style> Taken from the project generated by vue cli. If you want to use your image as a module, do not forget to bind data to your Vuejs component: <template> <div id=”app”> <img :src=”image”/> </div> </template> <script> … Read more