link1918 link1919 link1920 link1921 link1922 link1923 link1924 link1925 link1926 link1927 link1928 link1929 link1930 link1931 link1932 link1933 link1934 link1935 link1936 link1937 link1938 link1939 link1940 link1941 link1942 link1943 link1944 link1945 link1946 link1947 link1948 link1949 link1950 link1951 link1952 link1953 link1954 link1955 link1956 link1957 link1958 link1959 link1960 link1961 link1962 link1963 link1964 link1965 link1966 link1967 link1968 link1969 link1970 link1971 link1972 link1973 link1974 link1975 link1976 link1977 link1978 link1979 link1980 link1981 link1982 link1983 link1984 link1985 link1986 link1987 link1988 link1989 link1990 link1991 link1992 link1993 link1994 link1995 link1996 link1997 link1998 link1999 link2000 link2001 link2002 link2003 link2004 link2005 link2006 link2007 link2008 link2009 link2010 link2011 link2012 link2013 link2014 link2015 link2016 link2017 link2018 link2019 link2020 link2021 link2022 link2023 link2024 link2025 link2026 link2027 link2028 link2029 link2030 link2031 link2032 link2033 link2034 link2035 link2036 link2037 link2038 link2039 link2040 link2041 link2042 link2043 link2044 link2045 link2046 link2047 link2048 link2049 link2050 link2051 link2052 link2053 link2054

[Vue.js] Nuxt app freezing while using nested routes

In the index (home page), if I click a button and navigate to:


it freezes the browser and there is no response with blank white page!

However, if I enter manually this url, it works.

my pages directory structure:



I found an issue on github but it doesn’t helped me!

App freezes while using nuxt-link and nested routes with redirect

Solution :

It looks like the issue is actually related to the issue on github you linked to.

If I understand you correctly the pages directory is like so:

|-browse (folder)
| |-songs (folder)
| |-new (folder)
| index.vue.js (file)
|-browse.vue.js (file)
|-index.vue.js (file)

This would be causing confusion for nuxt because you basically have two different things trying to be the same thing, the ‘browse’ folder and the ‘browse’ file.

You should try it like this:

|-browse (folder)
| |index.vue.js (file) //this replaces the browse.vue.js file and can be found at http://localhost:3000/browse
| |-songs (folder)
| |-new (folder)
| index.vue.js (file) //this can be found at http://localhost:3000/browse/songs/new
|-index.vue.js (file)

If the above breaks a nuxt-child arrangement the following seems to work.

|-browse (folder)
| |index.vue.js (file)
| |-songs (folder)
| |-index.vue.js
| |-new (folder)
| index.vue.js (file)
|-index.vue.js (file)

Because of the nesting of the routes, to find the <nuxt-child/> of each you need to include it in an index.vue.js at each level. The file can contain simply this:

//browse-index.vue.js && browse-songs-index.vue

but it keeps the child chain alive.

[Vue.js] Should I work in the blade.php or use a component for a Laravel + Vue web app

I’m building a Narrow Casting System that displays tickets from a 3rd party API. The backend is handled with Laravel, and the frontend with Vue.

when wondering if I should get all the components in the blade.php file or make a vue.js component which loads them individually (A wrapper for the components, sort of), and then loading a single component in the blade.php.

Solution :

Loading components individually give you the benefit of lazy loading (async loading), making you app load fast and perform better, saving requests loading a single bundle with all you need.

Putting all components in a blade file is not readable, hard to maintain, you can’t say if that component is a dependency of another or is an entry point.

[Vue.js] How to keep waiting Vue until getting data from firebase?

there is a project that showing posts from a firebase realtime database. I use Vue, Vue-Router and Firebase Authentication. Firstly, when a user open the website, user see a login screen. In that screen page loads the posts from my database. Then when user login he/she routing to my Home.vue.js page. In here posts are showing there is no problem. But when user refresh the page, elements that are in the Home.vue.js are loading faster than my firebase data. to fix it.

That is my function that loads late from another javascript file:

function getData(data) {
var posts = data.val();
var keys = Object.keys(posts);

for(var i = 0; i < keys.length; i++) {
var id = keys[i];
var user = posts[id].user;
var text = posts[id].text;
var date = posts[id].date;
id: id,
user: user,
text: text,
date: date

export var userPosts = [ ];

Solution :

You gotta look for lifecycle hooks in vue.js and use the one hook that triggers before/when the page is (re)loaded.. In it you set a Promise with the firebase function, that triggers getData() when resolved and go through with the chosen lifecycle hook.

[Vue.js] RegExp inside of switch case inside of debounce not working

I’m working with a VueJS app that takes a search input and when then going to query different APIs based on the term. My first regexp is only supposed to match on numbers that are up to 7 digits. However, it is matching on anything.

I’m assuming the debounce and the switch/case statement is causing some confusion - but I’m not sure.

In the end, I’m going to need to have 6 or 7 different regexp tests that I will be checking against so I need to get this to work.

Does anyone have an idea what I’m doing wrong?

Sample JS:

Vue.component(“v-select”, VueSelect.VueSelect);

new Vue({
el: “#app”,
data: {
options: []
methods: {
onSearch(search, loading) {
loading(true);, search, this);
search: _.debounce((loading, search, vm) => {
console.log(‘search term is ‘+ search);
var regex1 = /([0-9]){0,7}/;

case regex1.test(search):
console.log(‘we have a number ‘+ search);
console.log(‘default case ‘+ search);
fetch(`${escape(search)}\`).then(res => {
res.json().then(json => (vm.options = json.items));
}, 350)

Codepen example:

Console shows the output. Try to search for a regular word like “vue” or “library”. Those are triggering the number regexp for some reason.

Solution :

Indeed /([0-9]){0,7}/ will let any string pass, because it allows zero digits without any restrictions on the rest of the string.

So add ^ and $ anchors to the regex. You don’t need the parentheses, and \d is [0-9]:


[Vue.js] Vue multiselect with axios call to database, laravel

For some reason, I can’t quite figure out how to get an ‘autocomplete’ style multiselect with vue.js working properly.

I properly set the route that is being called in my axios block, and the controller is set to use the query as a way to hit the database with a LIKE clause, but something is going wrong somewhere and my multiselect is not being filled with results from database that would make it searchable.

What am I doing wrong here?


Route::get(‘search’, ‘Controller@searchTags’)


public function searchTags(Request $request)
if ($request->get(‘query’)) {
$query = $request->get(‘query’);
$data = TAGS::where(‘TAG_DATA’, ‘LIKE’, “%{$query}%”)->get();

$output = ‘<ul class=”dropdown-menu” style=”display:block; position:relative”>’;
foreach ($data as $row) {
$output .= ‘<li><a href=”#”>’ . $row->tag_data . ‘</a></li>’;
$output .= ‘</ul>’;

return $output;


<div id=”tagContent”>
<multiselect v-model=”value” open-direction=”bottom” :options=”options” :multiple=”true” :close-on-select=”false” :taggable=”true” :clear-on-select=”false” :preserve-search=”true” placeholder=”Add Tag(s)” label=”name” track-by=”name”>
<template slot=”selection” slot-scope=”{ values, search, isOpen }”><span class=”multiselect__single” v-if=”values.length && !isOpen”>{ values.length } options selected</span></template>

new Vue({
components: {
Multiselect: window.VueMultiselect.default
data () {
return {
value: [],
options: []
methods: {
window.axios.get(‘campaigns/search’).then(({ data }) =>{
addTag (newTag) {
const tag = {
name: newTag,
code: newTag.substring(0, 2) + Math.floor((Math.random() * 10000000))

Solution :

There are a few things missing from the example, I believe.

You need to trigger the read function when the search input changes - use the @search-change event for that
You need to make use of the results of the axios request by sending them to this.options, so that the multiselect component can make use of them.

In this example, I’ve mocked the data request using a timeout, but you should get the idea. You can also make use of the loading property to let the users know something is happening behind the scenes.

[Vue.js] Django REST Files Images Uploading

Im want to upload an image using Vue.js and Django-rest. And have few problems with it.

Im trying to use put request (as in docs) and FileUploadParser for it, but getting an error:

detail: “Missing filename. Request should include a Content-Disposition header with a filename parameter.

If i make my header like:

‘filename’: ‘file’

Django registers request as OPTIONS, not put, so my put function not called.

My serializer:

class ImagesSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Images
fields = (‘image’,)

My view:

class ImagesViewSet(APIView):
parser_classes = (FileUploadParser,)

def get(self, request):
images = Images.objects.all()
serializer = ImagesSerializer(images, many=True)
return Response(

def put(self, request, filename, format=None):
image =[‘image’]

return Response(status=204)

My Vue.js request:

import axios from ‘axios’;

export default {
name: ‘App’,
return {
name: ‘’,
image: ‘’,
description: ‘’,
price: ‘’,
files: false,
methods: {
onFileChange(e) {
var files = || e.dataTransfer.files;
if (!files.length)
createImage(file) {
var image = new Image();
var reader = new FileReader();
var vm = this;

reader.onload = (e) => {
vm.image =;

const config = {
headers: {
‘filename’: ‘file’

let formData = new FormData();
formData.append(‘image’, this.image);

}, config).then(response => {
}, response => {

What im doing wrong, or what did i miss?

Solution :

File uploading in Django REST framework is the same with uploading files in multipart/form in django.

To test it you can use curl:

curl -X POST -H “Content-Type:multipart/form-data” -u {username}:{password} \
-F “{field_name}=@{filename};type=image/jpeg” http://{the api endpoint}

You can try solution find here on stackoverflow


Solution 2:

In addition to the content-type header, you’re going to want to add a content-disposition header, like so:
headers: {
‘Content-Disposition’: ‘attachment; filename=file’,
‘filename’: ‘file’

[Vue.js] Nuxt export 'default' (imported as 'mod') was not found

when using Nuxt with Typescript. I create a following component:

<div class=”field”>
<label class=”label” v-if=”typeof label !== ‘undefined’”>{ label }</label>
<div class=”control”>
v-if=”inputType === ‘textarea’”
@input=”$emit(‘input’, $”
v-if=”inputType === ‘input’”
@input=”$emit(‘input’, $”

<script lang=”ts”>
import { Vue, Component, Prop } from “vue-property-decorator”

export default class AppInput extends vue.js {
@Prop({ type: String, required: false, default: “input” })
inputType!: string

@Prop({ type: String, required: false })
label!: string

@Prop({ type: String, required: false, default: “text” })
type!: string


And then in @/plugins/components.ts, I import the component as following:

import vue.js from “vue”
import AppInput from “@/components/Forms/AppInput.vue”

Vue.component(“AppInput”, AppInput)

When I compile the project with Nuxt, it throws me export ‘default’ (imported as ‘mod’) was not found error. Please help!

Solution :

I solved using the following tsconfig:

“compilerOptions”: {
“target”: “esnext”,
“module”: “esnext”,
“moduleResolution”: “node”,
“lib”: [“esnext”, “esnext.asynciterable”, “dom”],
“esModuleInterop”: true,
“experimentalDecorators”: true,
“allowJs”: true,
“sourceMap”: true,
“strict”: false,
“allowSyntheticDefaultImports”: true,
“noImplicitAny”: false,
“noEmit”: true,
“baseUrl”: “.”,
“resolveJsonModule”: true,
“paths”: {
“~/*“: [“./*“]
“types”: [“@nuxt/vue-app”, “@types/node”, “@types/webpack-env”]

[Vue.js] How to pass argument to a function in VueJS

I’m trying to pass two arguments (epoch time) to three differents function in this order : .vue.js -> module.js -> api.js, but at the module function one of my argument is apparently replace by an object and there is no idea why.

The result i get from my console.logs :

vue.js ds: 1526256000000 -de 1530662400000
Module ds: Object { dispatch: dispatch(), commit: commit(), getters: {},state: {}, rootGetters: {}, rootState: {}-de 1526256000000 mkt-module.js:20
API ds: Object { dispatch: dispatch(), commit: commit(), getters: {}, state: {}, rootGetters: {}, rootState: {} }-de 1526256000000

What i’v tried so far :

I tried changing the value, and reversing date_start/date_end, but in the end only the date_start is turned into an object.

Here’s the code i’m using :


Date Start : <input type=”date” v-model=”date_start”> - Date End : <input type=”date” v-model=”date_end”><button type=”button” v-on:click=”get_connections” class=”btn btn-dark”>Run</button>
<p>remote connections : { connections }</p>


import { mapActions, mapState } from ‘vuex’

export default {
data () {
return {
date_start: ‘2018-07-04’,
date_end: ‘2018-07-04’
methods: {
connections_interval: ‘mkt/connections_interval’,
async get_connections() {

var date_start = new Date(this.date_start).valueOf()
var date_end = new Date(this.date_end).valueOf()
console.log(“vue.js ds:”,date_start,”-de”,date_end)
var cons=this.connections_interval(date_start,date_end); // i send the args to the function inside module_mkt.js


import { connections_interval } from ‘@/api/mkt-api’
export default {
namespaced: true,
actions: {
connections_interval(date_start,date_end) {
console.log(“Module ds:”,date_start,”-de”,date_end)
const response = connections_interval(date_start,date_end) // i send the args to the function inside mkt-api.js
return response


import axios from ‘axios’

export const connections_interval = (date_start,date_end) => (
console.log(“API ds:”,date_start,”-de”,date_end),
axios.get(`/api/DeviceEvents/connections_interval`, {
params: {
date_start: date_start,
date_end: date_end

If anyone as any idea why it is replace it would save me, thanks again for the time.

Solution :

You need to accept the custom payload as the Second parameter in action method. And since you have multiple arguments so, use Object.

// file.vue

async get_connections() {

// send object as arguments
var cons = this.connections_interval({ date_start, date_end });

// mkt-module.js
actions: {
// first parameter is store object & second parmeter is the custom payload
connections_interval(store, { date_start, date_end }) {
console.log(“store: “, store);
console.log(“Module ds:”, date_start”-de”,date_end)
const response = connections_interval(date_start, date_end);
return response

Solution 2:

In my experience, the action in vuex can just receive one parameter.

So you have to pass


In the action, the first params is included the params that passed from the vuex store. the params you pass in the view should be get in the second params. It should be:


import { connections_interval } from ‘@/api/mkt-api’
export default {
namespaced: true,
actions: {
connections_interval({ dispatch, commit, state}, {date_start,date_end}) {
console.log(“Module ds:”,date_start,”-de”,date_end)
const response = connections_interval(date_start,date_end) // i send the args to the function inside mkt-api.js
return response

Solution 3:

Take a look at official docs:

// `mapActions` also supports payloads:
‘incrementBy’ // map `this.incrementBy(amount)` to `this.$store.dispatch(‘incrementBy’, amount)`

All actions in Vuex only accepts one argument as payload.

You can fix it like this:

async get_connections() {
// ……
var cons=this.connections_interval({ date_start, date_end });
// ……

In module:

import { connections_interval } from ‘@/api/mkt-api’
export default {
namespaced: true,
actions: {
connections_interval({ date_start, date_end }) {
// ……

[Vue.js] vue and vue-material how to start?

After creating a fresh new project using vue.js create, I would like to integrate vue.js material, from

I installed, via npm, the package

npm install vue-material –save

But then when I reach the following instruction I don’t know what to do

It’s optional, but to have the best experience possible, use Roboto and Google Icons from Google CDN:

<link rel=”stylesheet” href=”//>

Where is supposed I add this line?

I’ve no .thtml file, there is a main.js, App.vue, HelloWorld.vue, but no .html.

How to integrate it with a base .vue.js project?

Solution :

Thanks to @Phil

I didn’t see the public/index.html.

[Vue.js] How to fix This is probably not a problem with npm. There is likely additional logging output above. error?

I’m trying to create a project using vue.js CLI. But I received this error message:

throw er; // Unhandled ‘error’ event

Error: getaddrinfo ENOTFOUND x86_64-apple-darwin13.4.0
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:58:26)
Emitted ‘error’ event at:
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1440:12)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:58:17)
npm ERR! errno 1
npm ERR! hello-world@0.1.0 serve: `vue-cli-service serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hello-world@0.1.0 serve script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/jeong-ugim/.npm/_logs/2019-04-09T03_17_05_336Z-debug.log

I just followed the installation step on “". I did npm install -g @vue/cli and vue.js create hello-world. As soon as I committed npm run serve, the error message showed up. I looked at the error log, but I couldn’t find out what caused my problem.

I tried to update npm. I just can’t find what is wrong with my computer or code.

How can I fix this problem? Thank you for any help or suggestion.

This is the error log.

0 info it worked if it ends with ok
1 verbose cli [ ‘/Users/jeong-ugim/.nvm/versions/node/v11.12.0/bin/node’,
1 verbose cli ‘/Users/jeong-ugim/.nvm/versions/node/v11.12.0/bin/npm’,
1 verbose cli ‘run’,
1 verbose cli ‘serve’ ]
2 info using npm@6.7.0
3 info using node@v11.12.0
4 verbose run-script [ ‘preserve’, ‘serve’, ‘postserve’ ]
5 info lifecycle hello-world@0.1.0~preserve: hello-world@0.1.0
6 info lifecycle hello-world@0.1.0~serve: hello-world@0.1.0
7 verbose lifecycle hello-world@0.1.0~serve: unsafe-perm in lifecycle true
8 verbose lifecycle hello-world@0.1.0~serve: PATH: /Users/jeong-ugim/.nvm/versions/node/v11.12.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/jeong-ugim/Programming/hello-world/node_modules/.bin:/Users/jeong-ugim/.nvm/versions/node/v11.12.0/bin:/Users/jeong-ugim/anaconda3/bin:/Users/jeong-ugim/anaconda3/condabin:/Users/jeong-ugim/anaconda/bin:/Users/jeong-ugim/anaconda/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/jeong-ugim/anaconda/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
9 verbose lifecycle hello-world@0.1.0~serve: CWD: /Users/jeong-ugim/Programming/hello-world
10 silly lifecycle hello-world@0.1.0~serve: Args: [ ‘-c’, ‘vue-cli-service serve’ ]
11 silly lifecycle hello-world@0.1.0~serve: Returned: code: 1 signal: null
12 info lifecycle hello-world@0.1.0~serve: Failed to exec serve script
13 verbose stack Error: hello-world@0.1.0 serve: `vue-cli-service serve`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/Users/jeong-ugim/.nvm/versions/node/v11.12.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:197:13)
13 verbose stack at ChildProcess.<anonymous> (/Users/jeong-ugim/.nvm/versions/node/v11.12.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:197:13)
13 verbose stack at maybeClose (internal/child_process.js:988:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
14 verbose pkgid hello-world@0.1.0

Solution :

Thank you @Riddhi and @WebMan. I resolved my issue through setting auto_activate_base to be False.

This is the code I used: conda config –set auto_activate_base False

I can’t still understand why I needed to disable (base) in front of my terminal prompt. But everything seems to be working.