link274 link275 link276 link277 link278 link279 link280 link281 link282 link283 link284 link285 link286 link287 link288 link289 link290 link291 link292 link293 link294 link295 link296 link297 link298 link299 link300 link301 link302 link303 link304 link305 link306 link307 link308 link309 link310 link311 link312 link313 link314 link315 link316 link317 link318 link319 link320 link321 link322 link323 link324 link325 link326 link327 link328 link329 link330 link331 link332 link333 link334 link335 link336 link337 link338 link339 link340 link341 link342 link343 link344 link345 link346 link347 link348 link349 link350 link351 link352 link353 link354 link355 link356 link357 link358 link359 link360 link361 link362 link363 link364 link365 link366 link367 link368 link369 link370 link371 link372 link373 link374 link375 link376 link377 link378 link379 link380 link381 link382 link383 link384 link385 link386 link387 link388 link389 link390 link391 link392 link393 link394 link395 link396 link397 link398 link399 link400 link401 link402 link403 link404 link405 link406 link407 link408 link409 link410

[Vue.js] Why laravel vue js automatically converting into get method Subscribe to RSS

vue.js.js get method is working instead of post method.
but in localhost its working perfectly.
Only facing this issue when i’m upload project into server

export default {
return {
form: new Form({
company_name : ‘’,
address : ‘’,
contact_name : ‘’,
number : ‘’,
keyword_or_comment : ‘’,
attachment : ‘’
methods: {
const url = `${API_URL}/api/apiurl/`;
.then(() => {{
type: ‘success’,
title: ‘Phone book added successfully’
.catch(() => {
created() {

Anyone can help me,
thanks in advance.

Solution :

I will suggest you to use axios Ajax request. this is highly recommended for vue.js js.

like:, { body: this.body })
.catch(error => {
flash(, “danger”);
.then(({ data }) => {
this.body = “”;


[Vue.js] How to get the event info in Vue.js? Subscribe to RSS

I’m trying to use vue.js Devtools to debug my App and I was wondering how to retrieve the info I see after an event.

<l-marker v-for=”marker in markers”

My event is @dragend=”dragend”,How can I get the lat and lng values?

Edit: Is this correct?

dragend: function(event){


Solution :

if you edit the attribute in


you will have the position always updated within the property marker.position, without using @dragend event

[Vue.js] VUEJS Is it possible to process/modify data retrieved through v-for before displaying? Subscribe to RSS

Hello when extremely new to web application development / javascript in general. Only gave myself crash courses from udemy videos for the past 4 months.

For my web application, when retrieving data from a database through my server-side backend with axios. there is a logRepository Array where the retrieved data is pushed.

data() {
return {
logRepository: [],
created() {
axios.get(‘/myrestapiroute’, {
headers: {
‘Authorization’: `Bearer ${this.$store.state.token}`
params: {
userId: this.userId
.then(res => {
const data =
this.dataCheck = data
for(let key in data) {
const log = data[key] = key

On my template, I used v-for to loop through all the retrieved data elements:

<div ….. v-for=”(log,index) in logRepository” :key=”index”>

With the v-for in place, one example of how I display my data as such in a paragraph tag. The format is due to how the data was structured.

<p style=”text-align: justify;”>
{ log.logId.jobPerformed }

The problem arises when I try to apply styling to the text. As you can see above, I would like to use text-align: justify. I also wanted to keep the whitespace as how it was input by the user through the use of white-space: pre-wrap.


But the problem is these two styles do not work together well. As can be seen below in the picture, if I use justify on its own, it behaves normally (Except that whitespace is lost). However, if I combine both text-align:justify and white-space: pre-wrap, the text end up justified with spacing, but aligned in a weird way.


For short entries, they begin with weird indentation when the starting side should be aligned to the left of the column. The issue appears to be more than simply whitespaces at the start as there is tried .trim() as suggested by a contributor.


I tried to tweak the CSS around, with text-align-last, text-align-start, direction: ltr, pre-tags etc. But it just does not work properly. Suggestions from other SO pages recommended that the data be processed by performing a string replace of all \n to br before displaying.

Is it possible to perform processing for individual data obtained from v-for before displaying or it has to be done to the array using computed property?

Since my data is to be fetched from a database, when confused on how to achieve the pre-processing of data, since my array size will dynamic and differ for each user.

What would be the most optimal way to achieve pre-processing of data before displaying for such case?

This image below is how my Array of Object (logRepository) looks like. The format is largely due to mongoDB schema.

\======= Solution =======

I modified the object variables in my .then block and performed string replace for all \n characters to tags.

With that my display no longer requires the “white-space: pre-wrap” styling. However, since I was previously using string interpolation to display my data the tags were treated as plain text.

I had to modify the tags to use v-html binding to display the data as htmltext so that would work. The difference can be seen in the last picture.

Thanks for helping me on this since when very new to javascript.

Solution :

There are a number of patterns you could use here to pre-process the data.

Process the data in the then function you have created
Wrap the data in functions within the { … } blocks in the template
Create a component that is used as the element that the v-for loop iterates over which displays a computed value
Use a computed value as the source array of the v-for directive in the main template. This is often done using a processing function mapped to the source data, as in data => data.logId.jobPerformed.trim()

[Vue.js] Display objects with the same key in one row Subscribe to RSS

I got this objects


0114 is a county in sweden.

1 is symbolizes men

2013… is the years

values is the amount of men born in ex. 2013

to display them like this:

How it looks right now:

How i’m displaying rightnow :

<div class=”tabellWrapper”>
<table class=”kommunerMainWrapper” >
<td >Kommun</td>
<th >Kn</th>
<th >2013</th>
<th >2014</th>
<th >2015</th>
<th >2016</th>
<th >2017</th>
<tbody class=”kommunerWrapper” >
<template v-for=”(data,index) in selectedLanData”>
<tr v-if=”data.key[1] ===’1’” :key=”index”>
<th class=”kommunerItem kommun”>{data.key[0]}</th>
<th class=”kommunerItem sex” >Mn</th>
<th class=”kommunerItem numbers”>{data.values[0]}</th>
<th class=”kommunerItem numbers”>{data.key[2]}</th>
<tr v-else :key=”index”>
<th class=”kommunerItem kommun”>{data.key[0]}</th>
<th class=”kommunerItem sex” >Kvinnor</th>
<th class=”kommunerItem numbers”>{data.values[0]}</th>
<th class=”kommunerItem numbers”>{data.key[2]}</th>

Solution :

I think you should parse the data array before. If it is a possibility for you, this could be the code:

var source = [

var parsed = {};

for (var i=0; i<source.length; i++) {
var key = source[i].key;
if (!(source[i].key[0] in parsed)) {
parsed[source[i].key[0]] = {};
if (!(source[i].key[1] in parsed[source[i].key[0]])) {
parsed[source[i].key[0]][source[i].key[1]] = {};
if (!(source[i].key[2] in parsed[source[i].key[0]][source[i].key[1]])) {
parsed[source[i].key[0]][source[i].key[1]][source[i].key[2]] = 0;
parsed[source[i].key[0]][source[i].key[1]][source[i].key[2]] += parseInt(source[i].values);


Solution 2:

You can simply do it with the reduce function as so:

const data = [

const tableRows = data.reduce((rows, value) => {
let currentRow = rows.find(row => row.region === value.key[0] && row.gender === value.key[1]);
if (!currentRow) {
currentRow = {region: value.key[0], gender: value.key[1]};
currentRow[value.key[2]] = value.values[0];
return rows;
}, []);


[Vue.js] CSS grid - count number of columns (javascript) Subscribe to RSS

there is a CSS grid

.wrapper {
display: grid;
grid-template-columns: repeat(auto-fill, 12.5vw );
grid-template-rows: repeat(auto-fill, 12.5vw );
background-color: black;
grid-auto-flow: row dense;
color: #444;

<div class=”wrapper”>
<div class=”box wide tall a”>
<div class=”box b”>
<div class=”box c”>
<div class=”box c”>
<div class=”box d”>
<div class=”box e”>
<div class=”box f”>
<div class=”box g”>
<div class=”box h”>

And I would like to know the number of columns in my javascript code. is it possible?

EDIT: the reason this is that if there is less than the good amount of items so that it makes a square, these extra items not to be displayed at all.

Thanks a lot!

Solution :

You can use getElementsByClassName to retrieve all the box divs and get the array length:

var columns = document.getElementsByClassName(‘box’).length

Solution 2:

I think you are missing the minmax part of the grid-template-columns:
eg grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));

with out it, you will always have 7 columns, and the grid columns wont be responsive and change as page width shrinks/expands.

can see Jen Simmons example page here : Spice Gallery Layout

A Solution that doesnt require any javascript.. but a few media queries..
is to wrap the .wrapper div with a container. and set a max height. per screen break point when every there would be un even images on the last row.
then set the .container overflow-y:hidden;

link to pen here : Hide last row of grid with css

Doing this with javascript you would need to know how many images you have, and what the minmax column widths are. vw units are basicaly width in %. so you would need to do some maths. with a mod function to know how many items are on the last row. and then need a way to hide them.

[Vue.js] What is jQuery like syntax doing in Vue.js? Subscribe to RSS

I was just going through some Vue.js code HERE and came across the following line of code:

.svg-icon.streak(v-html=”icons.streak”, v-b-tooltip.hover.bottom=”$t(‘streakCounter’)”)

There is this jQuery like syntax $t() and i don’t quite understand it , what exactly is this function doing ? where is it coming from ? i see no such function being imported ?

Can somebody explain what this jQuery like syntax is doing ?

Solution :

This comes from the i18n :

// vue.js plugin to globally expose a ‘$t’ method that calls common/i18n.t.
// Can be anywhere inside vue.js as ‘this.$t’ or ‘$t’ in templates.

And you can find streakCounter here : (and in other translation file for different languages)

[Vue.js] Error 500 when I try to store data from Vue.JS by Laravel Subscribe to RSS

there is an issue with my code. When I try to store data using Vue.JS and Laravel i get error 500 in the console. I’m stuck on it for 6 hours.

- DashboardAdvantagesController.php:

public function store(Request $request)
‘icon’=> ‘required’,
‘title’=> ‘required’

$advantage = $request->HomepageAdvantages()->create([
‘icon’=> $request->icon,
‘title’=> $request->title

return response()->json([
‘advantage’=> $advantage,
‘message’=> ‘task has been created!’


- HomepageAdvantages

class HomepageAdvantages extends Model
protected $fillable = [
‘icon’, ‘title’, ‘text’,

API route

Route::post(‘/advantages/store’, ‘DashboardAdvantagesController@store’);

vue.js Component


console.log(this.advantage.title);‘', {icon: this.advantage.icon,
title: this.advantage.title})






My error:

Failed to load resource: the server responded with a status of 500
(Internal Server Error)

:8000/api/advantages/store:1 Failed to load resource: the server responded with a status of 500 (Internal Server Error)
2app.js:267 POST 500 (Internal Server Error)
dispatchXhrRequest @ app.js:267
xhrAdapter @ app.js:118
dispatchRequest @ app.js:706
Promise.then (async)
request @ app.js:513
Axios.<computed> @ app.js:533
wrap @ app.js:966
createTask @ app.js:1773
invokeWithErrorHandling @ app.js:9448
invoker @ app.js:9773
original._wrapper @ app.js:15126

Solution :


I’m not sure how you came up with this, as it will only work when you have a macro registered on the Request class. If so, please disregard this comment.

Otherwise, you’ll need to explicitly call the model using HomepageAdvantages::create().

[Vue.js] Vue $watch for array of objects Subscribe to RSS

when new to Vue. We are migrating code from dojo to Vue. I was trying to add watch to an Array of objects. My data in which there is to add watch is an array of objects and Objects again can have arrays.

Sample data:

ItemList: [
item: {
term: 1,
steps: [{}], ( Array )
parameter: [{}] ( Array)

almost 600 values
item: {
term: 2,
steps: [{}],
parameter: [{}]


almost 600 values

In old dojo the code was like this:

for (c = 0; c < itemList.length; c++) {
var itemWatch =,oldVal,newVal) {

//Here the name gives what value of array is changed . I need that for future
//logic. we can add watch on each item.

clonedItems: function(){
return JSON.parse(JSON.stringify(this.itemList));

deep: true,
handler: function (val, oldVal) {

This I tried which is working fine, but to get to know what value is changed of this will be heavy computation. This array can be of 100 items and each item have 600 items where we have arrays as well.

Please guide what is the best way to achieve the similar functionality what we have.

Solution :

here is a code from website :

var vm = new Vue({
data: {
a: 1,
b: 2,
c: 3,
d: 4,
e: {
f: {
g: 5
watch: {
a: function (val, oldVal) {
console.log(‘new: %s, old: %s’, val, oldVal)
// string method name
b: ‘someMethod’,
// the callback will be called whenever any of the watched object properties change regardless of their nested depth
c: {
handler: function (val, oldVal) { /* … */ },
deep: true
// the callback will be called immediately after the start of the observation
d: {
handler: ‘someMethod’,
immediate: true
e: [
function handle2 (val, oldVal) { /* … */ },
handler: function handle3 (val, oldVal) { /* … */ },
/* … */
// watch vm.e.f’s value: {g: 5}
‘e.f’: function (val, oldVal) { /* … */ }

[Vue.js] Using React.js and Vue.js Together in Laravel Subscribe to RSS

I really want to know, is it possible to using react.js and vue.js next to each other in a laravel? For Example, use ReactJs for admin dashboard and use VueJs for client dashboard. I know it’s technically and logically better to use one of them.
What do you think? Can we use them together?

Solution :

Yes. It is definitely possible. Polyglot programming is today’s reality. There are a couple of approaches you can take. A most common approach would be that of a micro-frontends.

How you implement micro-frontend is up to you! But in general, you will have two different SPA served on two different routes. You will interlink these two applications using hyperlinks/anchor tags. However, note that, doing something that is a big cost and really meant for very large applications and teams building them.

There are many leaf components like buttons, links, dropdown, etc. which you will end up developing and maintaining for both frameworks. State management, routing, services will be rewritten for each framework. It is incredibly painful to match consistent style guide across frameworks.

Nowadays, if you really need to go ahead with this approach, you can consider using custom-elements for the leaf components. They should work for many SPA frameworks (see the notes). This will help you save the trouble of reinventing the wheel.

Note: React is not very friendly with web-components. It fails on many advanced tests.

[Vue.js] Creating vue.js mobileapp Subscribe to RSS

to use vue.js for creating mobile app. Advice me please any ways. I know about crdova(phoneGap) but it’s web based app. I listened about vue-native, but there is some troubles with that. May be there is easer ways to create on vue.js?

Solution :

Vue.js is the perfect framework for creating good looking web interfaces easily. Since you are trying to create a mobile app, we have the following options:

Create responsive web app using vue.js and vuetify. User can open it in the desktop browser as well as mobile browser. If you really want to retrofit into a mobile app, you create a simply android app and use WebView to show the web app
You can create a native app from scratch. Creating a good looking native app would take a huge effort.