Software
Should I be seeing hundreds of nested calls in DevTools flame charts, when I'm supposedly pre-compiling all of my Vue components?
I assumed that by refactoring all of the components in this large application into single-file Vue components, and using Webpack with Vue production runtime only, I could eliminate these deep call stacks of hundreds of nested calls that appear to be assembling a virtual DOM. It takes about 1500ms for all the scripting. If I comment out the reference to the root element (i.e. it doesn't bind), the scripting takes about 300ms. This seems expensive. The 'array' is by far the biggest part of the heap profile. Am I actually successfully pre-compiling?
Rails 5.1+ Vuejs Webpacker: Normal Rails MVC vs Rails API
I am starting a new app using Rails 5.1 and Vue.js, with the built-in Webpacker Vue.js pack (generated via the --webpack=vue flag).
I am trying to understand the pros & cons of using a normal Rails MVC app vs a Rails API app (generating a Rails app with the --api flag).
$ rails new someapp --webpack=vue vs. $ rails new someapp --api --webpack=vueGiven the fact that Rails API has been merged into core since 2015, and built-in Webpack via the Webpacker gem is brand new (Rails 5.1, 2017), what would be the best way to build a Rails app, where the frontend is going to be Vuejs? Or, mostly Vuejs?
Stick to regular Rails with Webpacker Vue, or Rails API with Webpacker Vue? And what are the tradeoffs?
Some of this answer will simply come down to a conversation about full-stack MVC apps vs SPA apps with API. However, are there any specific Rails Way +Vue.js components workflow things I should consider, beyond the "this is a question of an fullstack MVC app vs. a SPA app."
I want to note that I realize that the answers are going to be somewhat stylistic preference. Some might prefer one over the other.
Both will work, but I would like to think about ease of use, compatibility and trade-offs of doing it one way verse the other.
Thank you.
Vue component css being overwriten by bootstrapp-sass on Laravel
I have a almost vanilla instalation of Laravel.
No matter what i do, all my scoped css inside the component is simply ignored and bootstrap-sass styles are applied instead.

How can i stop this from rappening?
Issue calling Vue Method via Vue Computed
I believe this issue is related to JS in general as opposed to VueJS. But I have the following Vue Method that returns a Firebase Call and returns the object asked for. This is working:
methods: { getSponsor (key) { db.ref('businesses').child(key).on('value', snap => { console.log(snap.val()) return snap.val() }) } }[Object]
Now, when I call this method from a computed property, it results in undefined:
computed: { sponsor () { console.log(this.getSponsor(key)) return(this.getSponsor(key)) } }Undefined
Why is this? Is it because of how I return my method?
Where To Place Firebase's OnAuthStateChanged-Method In A VueJS-Application?
I'd like to trigger the onAuthStateChanged-method of Firebase in my VueJS-Application.
Currently I am not able to stay logged in as a certain user, the onAuthStateChanged-method seems not to run.
my action is kicked off by ...
beforeCreate() { this.$store.dispatch('update_session') }... in my main App-Component.
the mutation looks like:
update_session(state) { auth.onAuthStateChanged().then((user) => { if (user) { // USE USER KEY state.user.current.key = user.uid // USE USER ROLE users.child(state.user.current.key).on('value', (snapshot) => { state.user.current.role = snapshot.val().role }) } }) }Echo.private laravel 5.4 not work
i working for real-time notification .
notification send but not real-time
i need to refresh page to enable receive
<script> import NotificationItem from './NotificationItem.vue'; export default { props: ['unreads', 'userid'], components: {NotificationItem}, data(){ return { unreadNotifications: this.unreads, } }, methods: { markNotificationAsRead() { if (this.unreadNotifications.length) { axios.get('markAsRead'); } } }, mounted() { console.log('Component mounted.'); Echo.private('App.User.' + this.userid) .notification((notification) => { console.log(asd); let newUnreadNotifications = {data: {thread: notification.thread, user: notification.user}}; this.unreadNotifications.push(newUnreadNotifications); }); } } </script> <template> <li class="dropdown" @click="markNotificationAsRead"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"> <span class="glyphicon glyphicon-globe"></span> Notifications <span class="badge alert-danger">{{unreadNotifications.length}}</span> </a> <ul class="dropdown-menu" role="menu"> <li> <notification-item :key="unread.id" v-for="unread in unreadNotifications" :unread="unread"></notification-item> </li> </ul> </li> </template>
script execute all but the following code not work
Echo.private('App.User.' + this.userid) .notification((notification) => { console.log(asd); let newUnreadNotifications = {data: {thread: notification.thread, user: notification.user}}; this.unreadNotifications.push(newUnreadNotifications); });
anyone can help plz ? i searched alot but not found solution ??
How should i include css files in .vue files?
I'm using official vue-cli scaffolder and trying to include normalize.css in App.vue this way
<style scoped> @import "/node_modules/normalize.css/normalize.css"; .app { font-family: Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-align: center; color: #2c3e50; max-width: 1000px; margin: auto; font-size: 16px; display: flex; align-items: center; justify-content: center; min-height: 100vh; } </style>But after compiling css doesn't include in style tag or as external file:
So, how can I correctly include this or another css file?
The worlds simplest vue.js/vuefire/firebase app. But can't read value
Vue.js is a bit of a life style change for a sql programmer, but getting there. Here I use vuefire as per specs, even manually inserting the correct key from my one record, one field Firebase DB to test it out. Yet see nothing returned or displayed.
Love to know how to do that! And fill in my one value form. From there the sky's the limit I'm sure. Thanks for any help.
ERROR MESSAGE: vue.common.js?e881:481 [Vue warn]: Error in mounted hook: "ReferenceError: residentsArray is not defined"
<template> <div class="edit"> <div class="container"> <p style="margin-bottom:10px;font-weight:800;">EDIT RECORD</p><br> <form id="form" v-on:submit.prevent="updateResident"> <fieldset class="form-group"> <label for="first_name">Name</label> <input type="text" class="form-control" id="first_name" name="first_name" v-model="currentResident.name"> </fieldset> <input type="submit" class="btn btn-primary" value="Add New Resident"> </form> </div> </div> </template> <script> import firebase from 'firebase' let editConfig = { apiKey: "123456789", authDomain: "myapp.firebaseapp.com", databaseURL: "https://myapp.firebaseio.com", projectId: "my", storageBucket: "myapp.appspot.com", messagingSenderId: "1234567890" }; var firebaseApp = firebase.initializeApp(editConfig, "Edit") var db = firebaseApp.database() let residentsReference = db.ref('residents') export default { name: 'Edit', mounted() { this.currentResident.name = residentsArray.name; }, firebase: { residentsArray: residentsReference.child('-KpzkbA6G4XvEHHMb9H0') }, data () { return { currentResident: { name: '' } } }, methods: { updateResident: function () { // Update record here } } } </script>Uncaught Error: [vue-router] "path" is required in a route configuration
I'm following the official example but I don't know why I get a blank page with this js error
vue-router.esm.js?fe87:10 Uncaught Error: [vue-router] "path" is required in a route configuration.
Here is my two pages:
/:language/bar /:language/foo +------------------+ +-----------------+ | +---------+ | | +---------+ | | | header | | | | header | | | +---------+ | | +---------+ | | +--------------+ | | +-------------+ | | | bar | | +------------> | | foo | | | | | | | | | | | +--------------+ | | +-------------+ | +------------------+ +-----------------+And this is how I'm trying to do it.
My entrypoint js file:
import Vue from 'vue'; import router from './router'; // import some components let vm = new Vue({ el: '#app', router, components: {/*imported components*/}, }); vm.$language.current = vm.$route.params.language;My entrypoint html
<body> <div id="app"> <!-- this is the header, the common part --> <navbar fullname=''></navbar> <router-view></router-view> </div> </body>My router
import Vue from 'vue'; import Router from 'vue-router'; // import foo and bar components Vue.use(Router); let routes = [ { path: '/:language', name: 'homepage', children: [ { path: 'foo', component: Foo }, { path: 'bar', component: Bar }, ] } ]; export default new Router({routes,});My foo component
<template> <div> <h1>FOO</h1> </div> </template> <script>export default {};</script>How do I fix this error?
Update template with model changed from input vueJS
I'm developing my first app in vueJs and laravel. now I 'have a problem with v-model. I have a page with component Person that edit or create new Person. So I get from my backend in laravel or Model Person or new Person.
Now in my frontend I pass data to component by props:
Page.blade.php
<Person :person-data="{!! jsonToProp($person) !!}"></Person>(jsonToProp transform model coming from backend in json) In this case, I would return new Model so without properties, so $person will be a empty object.
Person.vue
<template> <div> <label for="name_p"> Name</label> <input id="name_p" v-model="person.name" class="form-control" /> <button v-on:click="test()">test</button> {{person.name}} </div> </template> <script> export default { props: ['personData'], mounted() { }, data() { return { person: this.personData } }, methods:{ test(){ console.log(this.person.name); } } } </script>Now if I change input with model v-model="person.name" I would print name in template but it doesn't change. But if I click buttonit console write right value. So I read that changing model value is asynch, so How I can render new Model when change input?
How to get href attributr value in vue.js
I am new to vuejs and I am having a query i.e. How can we get the href attribute value of a HTML variable.
<pre> var custompath = '<a id="myid" href="undefined111">a8AZCtgt</a>' </pre>Thanks in advance
Vue - any way to reuse SLOT?
Im working on responsive Vue.js app with Uikit. I must create 2 menus - one for desktop version, one for mobile. So I must define same menu items 2 times, first for desktop links slot, second time for mobile. I dont want define it 2x. How can I deal with this problem elegantly? Any ideas?
<template id="app"> <app-layout> <template slot="navlinks-desktop"> <router-link to="/link1" tag="li" exact><a>Link 1</a></router-link> <router-link to="/link2" tag="li" exact><a>Link 2</a></router-link> </template> <template slot="navlinks-mobile"> <router-link to="/link1" tag="li" exact><a>Link 1</a></router-link> <router-link to="/link2" tag="li" exact><a>Link 2</a></router-link> </template> <transition name="fade" slot="content"> <router-view></router-view> </transition> <p slot="footer">Footer text</p> </app-layout> </template> <template id="app-layout"> <div class="main-container"> <header class="uk-margin-bottom"> <nav class="uk-navbar uk-navbar-attached"> <div class="uk-navbar-brand uk-hidden-small">My Application</div> <div class="uk-navbar-flip"> <ul class="uk-navbar-nav uk-hidden-small"> <slot name="navlinks-desktop"></slot> </ul> <div class="uk-navbar-toggle uk-button-dropdown uk-visible-small uk-dropdown-close" data-uk-dropdown="{mode: 'click'; justify: 'nav'}"> <div class="uk-dropdown uk-dropdown-navbar uk-dropdown-small"> <ul class="uk-nav uk-nav-dropdown"> <slot name="navlinks-mobile"></slot> </ul> </div> </div> </div> <div class="uk-navbar-brand uk-navbar-center uk-visible-small">My Application</div> </nav> </header> <div class="uk-container uk-container-center"> <main> <slot name="content"></slot> </main> </div> <footer class="uk-text-center fixed-bottom"> <slot name="footer"></slot> </footer> </div> </template>vue html5 editor how to get data
I tried to implement this editor in my app. But I do not know how to retrieve the data with @change in my case. (3 editors on the same page).
My code:
<script src="http://tai.coding.me/vue-html5-editor/vue-html5-editor.js"></script> <link href="https://cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet"/> <script src="https://cdn.bootcss.com/vue/2.2.6/vue.js"></script> <body> <div id="app"> <div v-for="content in contents" > <p> <span style="white-space: nowrap">content {{content.id}}: {{content.area}}</span> </p> <vue-html5-editor :content="content.area" :height="300" :show-module-name="showModuleName" @change="updateData(content.id)" ref="editor"></vue-html5-editor> </div> <script> Vue.use(VueHtml5Editor, { showModuleName: false, image: { sizeLimit: 512 * 1024, compress: true, width: 500, height: 500, quality: 80 } }) new Vue({ el: "#app", data: { contents: [ {id: 1,area: "<h3>vue html5 editor</h3>"}, {id: 2,area: "<h3>vue html5 editor</h3>"}, {id: 3,area: "<h3>vue html5 editor</h3>"} ], showModuleName: false, }, methods: { updateData: function (id,data) { // sync toto to component this.contents[id-1].area = data; } } }) </script> </body>
How does the first "updateData" work? How can I implement it in my code?
How to add libraries vue in laravel?
I'm using laravel 5.4, with webpack and vue. I'm not sure how to add new libraries to use in vue.
For example, I run
npm install --save jquery vue2-selectWhat do I need to do next? I need to add:
Import Selectize from 'vue2-selectize'or
Require ('vue2-selectize')In the
resources / assets / js / app.js
file or
resources / assets / js / bootstrap.js
?
Can someone help me with the correct order to work?
Thank you!
Dynamically render custom Vue component from json schema and bind v-model to another json schema
Here is how i use my custom components in my html
<custom-input v-model="person.name" :title="'Person Name'"> </custom-input> <custom-select v-model="person.country" :options="countryList" :title="'Country'"> </custom-select>What i want is to generate these 2 components with all the attributes using json schema and bind the v-model to another json schema. So i can iterate the json array which defines what component tag is what attributes it should have etc etc. and then bind the v-model to a data schema from the second json schema. I'm thinking about a proxyComponent that renders them but it will become too complicated since some components dont have v-model, instead they have @input event listener for their value
Json model data:
{ person: { name: '', country: '', }, }Json schema which defines the components
[ { tag: 'custom-input', attributes: { vModel: 'person.name', title: 'Person Name', }, }, { tag: 'custom-select', attributes: { vModel: 'person.country', options: 'countryList', title: 'Country', }, }, ]What is a proper way to deal with Vue.js props that from the response of backend
I am wondering that what is a proper way to deal with props in Vue.js if the prop is from the response of backend?
Ok, let's say the child component has a prop called person. a name is in person object.
<template> {{ person.name }} <template> <script> export default { name: 'ChildComponent', props:['person'], created(){ this.getName(); }, data(){return{name:''}}, methods:{ getName(){ this.name = this.person.name; } } </script>The parent component is like this
<template> <ChildComponent :person="person"></ChildComponent> <template> <script> export default { name: 'ParentComponent', created(){ this.getPerson(); } data(){ return { person: null } }, methods:{getPerson(){ // send request to server or api then update name sendrequest().then(person => { this.person = person}); }} </script>At first, before the get the response, there will be a warning can't get name from person. I know 2 methods to handle this:
- <ChildComponent :person="person" v-if="person"></ChildComponent>
- watch person prop in, every time the person is changed, rerun the getName() method in childcomponent or set name as a computed attribute.
So here is the question again, are they the proper way to handle this? Is there still some other methods like using Vuex?
Thx
How to access data variables in vuejs within a single file component
I am attempting to read a variable from within the data object of a Vue component.
This is the Vue template I'm using
<template> <section> <b-field label="Username"> <b-input v-model="username"></b-input> </b-field> <b-field label="Password"> <b-input type="password" password-reveal v-model="password"></b-input> </b-field> <b-field label="Engineer number"> <b-input type="number" v-model="engineer"></b-input> </b-field> <a class="button" @click="send_login">Login</a> </section> </template> <script> import {socket} from './../../main.js' export default { data() { return { username: '', password: '', engineer: '', } }, methods: { send_login: () => { console.log(this.engineer) } } } </script>this.engineer always print undefined.
If I wasn't using the template files then this works
let login = new Vue({ el: '#loginApp', data: { username: '', password: '', engineer: '', }, methods: { login: () => { console.log(login.engineer); }, }, });Any ideas on what I'm doing wrong?
code splitting vuex application
I have a vuex store and i'd like to apply code splitting on it.
Following this tutorial I tried this:
import Vuex from 'vuex' import Vue from 'vue' import createLogger from 'vuex/dist/logger' Vue.use(Vuex) const debug = process.env.NODE_ENV !== 'production' const store = new Vuex.Store({ strict: debug, plugins: debug ? [createLogger] : [], state: { loading: false }, mutations: { toggleLoading: (state) => { state.loading = !state.loading } }, getters: { loading: state => state.loading }, actions: { toggleLoading: ({commit}) => { commit('toggleLoading') } } }) import('./modules/userModule').then(userModule => { store.registerModule('user', userModule) }) import('./modules/tenantsModule').then(tenantsModule => { store.registerModule('tenants', tenantsModule) }) import('./modules/updatesModule').then(updatesModule => { store.registerModule('updates', updatesModule) }) export default storeBut the application fails :
webpack-internal:///24:739 [vuex] unknown getter: user
What am i doing wrong?
Unable to access `get` method in vue-resource
I have a tiny vue app where I'm wanting to use vue-resource to request an api endpoint.
- I've installed vue-resource via npm
- I've added the Vue.use(VueResource) lines to my bootstrap file
- I've setup my component like this to call the .get method
Blog.vue
... mounted () { this.fetchPosts() }, methods: { fetchPosts: () => { debugger; this.$http.get('my-url') .then(response => { console.log(response) }) } } ...I've seen a few github issues and SO posts which touch on this type of problem but most seem to relate to incorrect configuration which I don't think I have (happy to be proven wrong!)
The specific console error I get is:
Error in mounted hook: "TypeError: Cannot read property 'get' of undefined"
What's odd about this is that if you see my debugger line, if I console.log this.$http.get at that point I get:
function (url, options$$1) { return this(assign(options$$1 || {}, {url: url, method: method$$1})); }If I let the code run and then attempt the console.log afterwards I get:
Cannot read property 'get' of undefined
As a result I presume it's some kind of this context issue, but from what I can see the reference should be correct...shouldn't it?
Vuex interlocking state with another
My state is inter-dependent with another, something like this: https://jsfiddle.net/MagicMagnate/1zufrspx/
const store = new Vuex.Store({ state: { checkedNames: ['Jack', 'Mike'], interlockedState : 'foo' }, mutations: { updateChecked(state, payload) { state.checkedNames = payload state.interlockedState = 'bar' //trying to set the state but failed } }, actions: { updateChecked({ commit }, payload) { commit('updateChecked', payload) } } }) new Vue({ store, el: '#example', //data: {interlockedState:'foo'}, computed: { checkedNames: { get() { return this.$store.state.checkedNames }, set(str) { this.$store.dispatch('updateChecked', str) } } } })Only more complex with case and if else, I know I shouldn't mutate directly from state directly, but I'm running out idea on how to assign a new value to state to mutate so those two states aren't interlocked with each other.

