Software
Laravel Echo not receiving notification from pusher
I followed up some tutorials about echo and pusher. I configured all the project as necessary but object notifications not appear at browser. I uncoment the line
App\Providers\BroadcastServiceProvider::class,
The next files it's about what I'm using:
bootstrap.js
channels.php
PackageNotifications (class which I create the notifications)
Line which I create a new notification
broadcasting.php
.env
I created and registered a component in vuejs called notifications then I set it out what says in laravel notifications as you can see bellow.
Everything is connecting with Pusher but when I send any notification it appear at pusher but as mentioned at before, the object notification is not appearing.
Someone have some idea about what is happening? Thanks in advance
Loading and external Javascript file in Vue.js
How can I include and initialize an external javascript file mymain.min.js using VueJs with webpack?
Webpack.base.conf
resolve: { extensions: ['.js', '.vue', '.json'], alias: { 'vue$': 'vue/dist/vue.esm.js', '@': resolve('src'), 'sauJs': path.resolve(__dirname, '../src/assets/mymain.min.js'), } },Vue.js instance data missing when referencing vuex store
I'm attempting to use an api call to a django-rest backend to populate my data-store. The api-call appears to be working fine.
After loading index.html i can look at both store_.state.products and v.$store.state.products which both appear to have my json response from the API. You can see that here in the console after navigating to index.html:
and
However, v.$data as you can see appears to be empty.
Please find below my code.
products.js
//api get call Vue.use(VueResource) function get(url, request) { return Vue.http.get(url, request) .then((response) => Promise.resolve(response)) .catch((error) => Promise.reject(error)) } //data store const apiRoot = 'http://127.0.0.1:8000/api/product-list/?format=json' const store_ = new Vuex.Store({ state: { products: [] }, mutations: { 'GET_PRODS': function (state, response) { state.products = response.body; }, 'API_FAIL': function (state, error) { console.error(error) }, }, actions: { getProducts (store) { return get(apiRoot) .then((response) => store.commit('GET_PRODS', response)) .catch((error) => store.commit('API_FAIL', error)) } } }) //products component Vue.component('product', { template: "#product-template", props: ['product'], delimiters: ["[[","]]"], }) //root instance const v = new Vue({ el: '#app', store: store_, data : function () { return { //this works fine as expected with hardcoded objects fed as data //products : [ //{ // id:1, // name:'test', // brief:'descrip', //}, //{ // id:2, // name:'other', // brief:'something else', //} //] products : this.$store.state.products }; }, delimiters: ["[[","]]"], }) //populate store.state.products with api-call v.$store.dispatch('getProducts')index.html
<!DOCTYPE html> <html> <head> {% load static %} <link rel="stylesheet" href="{% static '/products/bootstrap.css' %}" /> <link rel="stylesheet" href="{% static '/products/bootstrap-theme.css' %}" /> <link rel="stylesheet" href="{% static '/products/base.css' %}" /> <link rel="stylesheet" href="{% static '/products/index.css' %}" /> <link rel="shortcut icon" href="{% static '/products/favicon.ico' %}" type="image/x-icon" /> </head> <body> <template id="product-template"> <div> <h1>[[ product.name ]]</h1> <h5>[[ product.brief ]]</h5> </div> </template> <div id="app"> <div class="container-fluid"> <div class="row title-row"> <h1 class="title">Products</h1> </div> <div class="row"> <product v-for="product in products" :product="product" :key="product.id"></product> </div> </div> </div> <script src="{% static "products/vue.js" %}"></script> <script src="{% static "products/vue-resource.js" %}"></script> <script src="{% static "products/vuex.js" %}"></script> <script src="{% static "products/products.js" %}"></script> </body> </html>Bootstrap-Vue card component image doesn't render
I am trying to get a simple Bootstrap card on a static website I am making in Vue.js. I am using Bootstrap-Vue for this. However, I cannot seem to get the image to show when I use the b-card with the img attribute. Here is the documentation on a card:
https://bootstrap-vue.js.org/docs/components/card
And here is my code that is not showing the image (all other text is rendering, even the github icon)
<b-card img="`../assets/q1.png`" title="7 Little Words" class="mb-2 col-md-6"> <!--The image above is not showing--> <h5 :style="{fontSize:1.3+'em', marginTop:20+'px'}">An addictive vocabulary puzzle for word nerds</h5> <div class="demo"> <a href="" :style="{marginBottom:10+'px'}">VIEW DEMO</a> </div> <div class="github"> <h4>Github</h4> <!--This image below is showing--> <a href=""><img src="../assets/GitHub.png" alt="GitHub"></a> </div> </b-card>I think it must have something to do with the img attribute in the b-card, but I am not sure how to fix it. Also, here is my error in the console:
http://localhost:8080/assets/q1.png 404 (Not Found)
VueJS Simple Alert Appear
Can someone help me make this simple alert work? What I wanted was if I click the trigger button, the text would appear but then the component should do its part.
I'm new and learning VueJS and now is in the components part but I haven't fully grasped it yet.
Here's the link: JSBIN
Snippet of the JS Script
Vue.component('alert', { template: '#alert', props: { errors:false }, data: function() { return { message:"" } }, methods: { appear: function (status) { if(status=="yes") { errors = true; message = "Appeared"; } } } }); var myapp = new Vue({ components: 'alert', el: '#app', data: { }, methods: { trigger: function() { this.$alert.appear("yes"); } } });Cannot access data from component method
I tried components methods in vue js. My code like this.
const Thread = Vue.component('threadpage', function(resolve) { $.get('templates/thread.html').done(function(template) { resolve({ template: template, data : function() { return { data : { title : "Data Table", count : this.GetData } }; }, methods : { GetData : function() { var data = {username : "newshubid", data : { page : 0, length : 10, schedule : "desc" } }; var args = {"data" : JSON.stringify(data)}; var params = $.param(args); var url = "http://example-url"; var result; DoXhr(url, params, function(response){ result = JSON.parse(response).data; console.log("load 1", result); }); setTimeout(function () { console.log("load 2", result); return result; }, 1000); } }, created : function(){ this.GetData(); } }); }); });But, when I trying to use {{ data.count }} in template. Not showing result what i want. Even I tried return result in GetData.
Whats my problem ? And how to access data from methods ? Please help me, i'm a beginner. Thanks
how to add permission control in laravel with vue project?
i'm adding vue js into my current laravel apps so i can make it SPA and thats mean laravel is only acting as backend and rest of it is controlled by vue js from rendering view to routing.
My current laravel apps using kodeine laravel-acl for controlling which page and which action that my user can do by simply
put this in route:
Route::get('admin', [ 'as' => 'admins.admin.index', 'uses' => 'UserController@index', 'middleware' => ['auth', 'acl'], 'can' => 'view.admin_view']);and if i just do this in view to hide some action if user don't have permission
@permission('view.admin_view') //some link or button @endpermissionand all these permission is stored in mysql database and each user have different set of permission.
but how to do that if i making it vue js SPA? since all route is controlled via vue js?
HOW do I right this links in my navigation bar in my vue.js project?
I want to right align my product and support links in my navigation bar. How do you align links in the navigation bar of a vue.js project overall?
This is the code.
<md-whiteframe class = "main-toolbar "> <md-theme name = "teal"> <md-toolbar class = ""> <router-link class = "nav-link " :to = " { name: 'levi' }" style = "color:white; text-decoration: none; ">levi</router-link> <router-link id = "nav"class = "nav-link" :to = "{ name: 'Product' }" style = "color:white; text-decoration: none;"> Product </router-link> <router-link id = "nav" class = "nav-link" :to = "{ name: 'Support' }" style = "color:white; text-decoration: none;"> Support </router-link> </md-toolbar> </md-theme> </md-whiteframe>Vue component not displayed Laravel5.4
I try to make broad cast notification laravel 5.4 and vuejs 2
but notification not appear
any one can help me ?
navbar.blade.php
Notification.vue
NotificationItem.vue
result npm run watch that errors appear
Web app with Vue.js 2 and Firebase stopped working properly
I had a web app hosted on my personal server. It was built with Vue.js 2 and it was working properly until last month that I checked.
Basically, it loaded some content from Firebase and after choosing some options in the app, it gave me a result.
Even if I try to display some text that is not from Firebase, it still refuses to show anything.
In the console, there are no errors, but the only message I noticed was this:
["add",{"textareas":[],"contenteditables":[],"iframes":[],"htmlghosts":[]}] bundle.js:8321:29
I'm not sure what it is. I don't know what is suddenly wrong and how to fix it.
watch for a property in vue component
I have an async operation in parent component and need to notify child, that this operation was completed. Could I watch in child for a property change. Somewhat like:
new Vue({ props:['parentReady'], watch:{ parentReady(val){ alert('parentReady prop was changed'); } } })Execute code after view update in vue.js
I want to perform a task (scrolling to bottom, since new elements where added) after a view has been updated by vue.
Here is my code:
export default { mounted() { this.connect(); }, connection: null, methods: { connect: function () { ... }, onMessage: function (msg) { this.messages.push(msg); this.scrollDown(); return true; }, scrollDown: function () { $("html, body").animate({ 'scrollTop': $(this).offset().top }, 100); }As you can see, the this.scrollDown(); is invoked after this.messages.push(msg);, so since the view is not updated immediately the scroll is not well performed. How is it supposed to be made?
How to store data in VueJS with Laravel 5.4
Im building application like real time dashboard. Using many databases and external APIs.
(The first Idea was AJAX + Laravel Queues, but I found VueJS and It's interesting.)
The idea is to get the data in background with Laravel Queues from all sources and then storage it localy. Next step is getting this data with VueJS.
The problem I have is the storage part. I dont have idea and actually dont know how to store it so VueJS can efficiently get this data from storage and on the other hand Laravel can save the data to it the same.
There will be many users loging in a system so I created the MySQL database for them but dont know, if it's a good solution.
Thanks for advices!
How to access data returned via method per item in v-for
I am calling a method from each item in a v-for. The method returns the proper object but I want to access that information in other pieces of my .card. Such as having the {{name}} reflect the sponsor's name returned from that method. Normally I would have the method push the data to Vue data and then access via item. But that would be strange to do for 200+ items. (Perhaps I'm missing something in that logic)
I have the following VueJS setup:
HTML:
<!--inside v-for--> <div class="card"> <p>{{ getSponsor(key) }}</p> <p>{{name}}</p> </div>JS:
firebase () { return { deals: db.ref('deals'), businesses: db.ref('businesses') } }, methods: { getDealSponsor (key) { db.ref('businesses').child(key).on('value', snap => { return snap.val() }) } }Rendering custom nested html in Vue.js
I'm moving a site from AngularJS 1.x that relies heavily on the $compile service (which is no longer available in Angular 2.x. In the application I have a directive that looks something like this <myDir elemId="someRestEndPointID"></myDir> and does the following:
1) A http call is made and the response returns a string that contains a directive <myDir elemId="someRestEndPointID"></myDir>
2) A call is made to the server to for /someRestEndPointID
3) Angular gets the content and renders and looks for another <myDir> tag
4) the process is repeated (recursive)
I have not yet found something that does this for our new framework Vue.js. Is there a similar feature or library that would achieve this logic in Vue.js?
VueJS and WP Rest API
I have a little issue here, I want to get posts (json format) from Wordpress Rest API, and I do not understand what am I missing here. Can someone helps me?
var App = new Vue({ el : '#app', data: { posts: '' }, beforeCreate: function(){ console.log('I am the first one!'); }, mounted: function(){ console.log('mounted fired'); posts = this.$resource('http://volkov.co.il/wp-json/wp/v2/posts?per_page=3'); posts.get(function(response){ this.$set('posts', response); }); }});And here is my html:
<div id="app"> <div class="row"> <div class="large-12 columns"> <article class="post-article" v-for="post in posts"> <h1>post title</h1> <h3>{{ post.id }}</h3> </article> </div> </div> </div> <script src="https://unpkg.com/vue/dist/vue.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/vue-resource/1.3.4/vue-resource.js"></script> <script src="js/app.js" charset="utf-8"></script>As you can see I am using vue-resource library. I am running this code from local machine. What am I missing here? Thanks
Vue2 - Using :checked on checkbox input, breaks default behaviour
I'm doing a "status update" component of sorts, in my actual component I'm marking the first custom checkbox (the circles at top, etc.) as checked...but for the CodePen below, I just marked them all as :checked='false' to iterate my issue.
The "twitter" checkboxes won't check and uncheck. The Facebook ones will.
I'm certain this has to do with the fact that I'm enabling/disabling a character counter on the twitter checkboxes. If you click one of the twitter checkboxes, you'll notice the character counter turn on, but the checkbox is never checked...
For example, in the method toggleMaxCharLength(), if I comment out self.enableMaxCharLength = true;, the checkbox work as they should.
If I remove the :checked='false' from the input v-for, works as it should...
How to access the router from winthin a component
I'd like to show a modal when /url/confirm/ is requested.
This is what've done so far:
// footer component import Modal from '../Modal/Modal'; export default { components: {Modal,}, data() { return { showModal: false, }; }, mounted() { if (window.location.href.match('/confirm/')) { this.showModal = true; } }, }; // my main js import MyFooter from './components/footer/MyFooter; import router from './router'; new Vue({ el: '#app', router, components: {MyFooter, /* other components too */} });And I combined with this https://router.vuejs.org/en/essentials/dynamic-matching.html#reacting-to-params-changes to cover all use cases?
This works but does not seem to be a vue way to do things, especially that I do the same thing in two different files.
How do I detect a /confirm/ route whose name is confirm in vue in order to display the modal from within my component footer?
Add class on click in vuejs
this my vue template
<div class="col-sm-4 col-xs-6 thumb" v-for="(photo, index) in photos" @click.prevent="check(index)"> <a class="thumbnail" :class="{'active': photo.checked}"> <img class="img-responsive" :src="photo.picture" alt=""> </a> </div>and this is check() method:
check(index) { if(!("checked" in this.photos[index])) this.photos[index].checked = true else this.photos[index].checked = !this.photos[index].checked },every thing seem good for me but it's not working what the problem could be???
Error when trying to display value using v-for in vue
I have some trouble with understanding an error I am receiving using vue.js and hope that someone can help me out here. I believe that it is a silly mistake but I am unable to spot it.
I am receiving this error here: Use of undefined constant providers - assumed 'providers'. I am using laravel and blade here. I receive this error in the browser. I assume that it has something to do with the way I am trying to display the providers object using v-for loop in vue.js and since I am a beginner, I am probably making a mistake here. Here is my code:
Component:
Vue.component('filter-section', { template: "#filter-template", props: ['providers'] }); // create a root instance new Vue({ el: '#home-filter-result' });Filter-blade.php
<div id="home-filter-result"> <filter-section v-for="item in providers" :providers='{!! $providers !!}'> </filter-section> <template id="filter-template"> {{ item }} </template> </div>Providers is an object in this format:
providers : Array[20] 0:Object
value1: '1'
value2: '2'
value3: '3'