108,131 questions
726
votes
16
answers
638k
views
Vue.js - How to properly watch for nested data
I'm trying to understand how to properly watch for some prop variation. I have a parent component (.vue files) that receive data from an ajax call, put the data inside an object and use it to render ...
569
votes
17
answers
659k
views
How can I get query parameters from a URL in Vue.js?
How can I fetch query parameters in Vue.js?
E.g.
http://somesite.com?test=yay
Can’t find a way to fetch or do I need to use pure JS or some library for this?
446
votes
15
answers
636k
views
Disable input conditionally (Vue.js)
I have an input:
<input
type="text"
id="name"
class="form-control"
name="name"
v-model="form.name"
:disabled="validated ? ''...
425
votes
25
answers
764k
views
Can you force Vue.js to reload/re-render?
Just a quick question.
Can you force Vue.js to reload/recalculate everything? If so, how?
371
votes
16
answers
227k
views
Vue.js - How to remove hashbang #! from url?
How to remove hashbang #! from url?
I found option to disable hashbang in vue router documentation ( http://vuejs.github.io/vue-router/en/options.html ) but this option removes #! and just put #
Is ...
362
votes
25
answers
829k
views
'Property does not exist on type 'never'
This is similar to #40796374 but that is around types, while I am using interfaces.
Given the code below:
interface Foo {
name: string;
}
function go() {
let instance: Foo | null = null;
let ...
346
votes
17
answers
388k
views
Call a Vue.js component method from outside the component
Let's say I have a main Vue instance that has child components. Is there a way of calling a method belonging to one of these components from outside the Vue instance entirely?
Here is an example:
...
319
votes
22
answers
438k
views
How to watch store values from vuex?
I am using vuex and vuejs 2 together.
I am new to vuex, I want to watch a store variable change.
I want to add the watch function in my vue component
This is what I have so far:
import Vue from '...
317
votes
9
answers
274k
views
Vue v-on:click does not work on component
I'm trying to use the on click directive inside a component but it does not seem to work. When I click the component nothings happens when I should get a 'test clicked' in the console. I don't see any ...
316
votes
29
answers
374k
views
Vue 2 - Mutating props vue-warn
I started https://laracasts.com/series/learning-vue-step-by-step series. I stopped on the lesson Vue, Laravel, and AJAX with this error:
vue.js:2574 [Vue warn]: Avoid mutating a prop directly since ...
304
votes
20
answers
498k
views
Vue Js - Loop via v-for X times (in a range)
How can I repeat a loop via v-for X (e.g. 10) times?
<!-- want to repeat this (e.g.) 10 times -->
<ul>
<li v-for="item in shoppingItems">
{{ item.name }} - {{ item....
302
votes
4
answers
274k
views
Passing event and argument to v-on in Vue.js
I pass a parameter in v-on:input directives. If I don't pass it, I can access the event in the method. Is there any way I can still access the event when passing the parameter to the function? Note ...
284
votes
8
answers
159k
views
`ref()` vs `reactive()` in Vue 3?
I checked a few guides for Vue 3 and noticed that in some examples they used reactive(), while in others they created the same thing with ref(). They seem to behave very similarly, but which one ...
269
votes
13
answers
83k
views
Vuex Action vs Mutations
In Vuex, what is the logic of having both "actions" and "mutations?"
I understand the logic of components not being able to modify state (which seems smart), but having both actions and mutations ...
262
votes
2
answers
123k
views
Is there a way to dispatch actions between two namespaced vuex modules?
Is it possible to dispatch an action between namespaced modules?
E.g. I have Vuex modules "gameboard" and "notification". Each are namespaced. I would like to dispatch an action ...
259
votes
17
answers
542k
views
How to set URL query params in Vue with Vue-Router
I am trying to set query params with Vue-router when changing input fields, I don't want to navigate to some other page but just want to modify URL query params on the same page, I am doing this:
this....
253
votes
14
answers
232k
views
VueJS conditionally add an attribute for an element
In VueJS we can add or remove a DOM element using v-if:
<button v-if="isRequired">Important Button</button>
but is there a way to add / remove attributes of a dom element eg for the ...
249
votes
12
answers
301k
views
Vuejs: Event on route change
On my main page I have dropdowns that show v-show=show by clicking on the link @click = "show=!show" and I want to set show=false when I change the route. Please advise me on how to realize ...
238
votes
33
answers
688k
views
VSC PowerShell. After npm updating packages .ps1 cannot be loaded because running scripts is disabled on this system
I design websites in VSC and PowerShell is my default terminal.
After updating and deploying a website to firebase earlier, I was prompted to update firebase tools - which I did using npm. ...
229
votes
5
answers
147k
views
How to call an action from within another action in Vuex?
I have the following setup for my actions:
get1: ({ commit }) => {
// things
this.get2(); // this is my question!
},
get2: ({ commit }) => {
// things
},
I want to be able to call one ...
220
votes
3
answers
120k
views
How to create and use an optional parameter in Vue Router?
I need to route to a certain component in two ways - one with a param, one without. I have searched for optional params and somehow can't find much info.
So my route:
{
path: '/offers/:member',
...
220
votes
4
answers
200k
views
Vue 'export default' vs 'new Vue'
I just installed Vue and have been following some tutorials to create a project using the vue-cli webpack template. When it creates the component, I notice it binds our data inside of the following:
...
216
votes
6
answers
264k
views
What is nextTick and what does it do in Vue.js?
I read the docs, but I still can't understand it.
I know what data, computed, watch, methods do, but what is nextTick() used for in Vue.js?
214
votes
16
answers
335k
views
Can vue-router open a link in a new tab?
I have a summary page and a detail subpage. All of the routes are implemented with vue-router (v 0.7.x) using programmatic navigation like this:
this.$router.go({ path: "/link/to/page" })
However, ...
205
votes
21
answers
307k
views
Vue: How do I call multiple functions with @click?
How can I call multiple functions in a single @click? (aka v-on:click)?
So far I tried
Splitting the functions with a semicolon: <div @click="fn1('foo');fn2('bar')"> </div>;
...