rashidlaasri / laravel-scout-and-vuejs Goto Github PK
View Code? Open in Web Editor NEWBuild search functionality with Laravel Scout and Vue.js
Build search functionality with Laravel Scout and Vue.js
it works fine, but since in this example you don't use assets it is still working like standalone solution.
if I move vue code from standalone app.js to the end of my resources\assets\js\app.js and compile it using gulp then it doesn't work anymore
const app = new Vue({
el: 'body',
data: {
furnitura: [],
loading: false,
error: false,
query: ''
},
methods: {
search: function() {
// Clear the error message.
this.error = '';
// Empty the furnitura array so we can fill it with the new furnitura.
this.furnitura = [];
// Set the loading property to true, this will display the "Searching..." button.
this.loading = true;
// Making a get request to our API and passing the query to it.
this.$http.get('/api/search?q=' + this.query).then((response) => {
// If there was an error set the error message, if not fill the furnitura array.
response.body.error ? this.error = response.body.error : this.furnitura = response.body;
// The request is finished, change the loading to false again.
this.loading = false;
// Clear the query.
this.query = '';
});
}
}
});
instead it gives me error in console
ReferenceError: Laravel is not defined
Стек-трейс:
@http://scout/js/app.js line 72 > eval:30:3
exec@http://scout/js/app.js line 116 > eval:1017:21
Client/<@http://scout/js/app.js line 116 > eval:1045:13
Promise$1@http://scout/js/app.js line 116 > eval:192:24
Client@http://scout/js/app.js line 116 > eval:1010:16
Http@http://scout/js/app.js line 116 > eval:1152:12
Http[method]@http://scout/js/app.js line 116 > eval:1181:16
search@http://scout/js/app.js line 148 > eval:42:4
bind/<@http://scout/js/app.js line 123 > eval:216:69
anonymous@http://scout/js/app.js line 123 > eval line 3041 > Function:1:9
handler@http://scout/js/app.js line 123 > eval:8652:7
app.js%20line%20116%20%3E%20eval:270:9
ReferenceError: Laravel is not defined[Подробнее]app.js%20line%2072%20%3E%20eval:30:3
here is screenshot
https://yadi.sk/i/-iqfuUgLwu9wE
then I commented this code in bootstrap.js
Vue.http.interceptors.push((request, next) => {
request.headers['X-CSRF-TOKEN'] = Laravel.csrfToken;
next();
});
and now I have infinite quantity of search results and a lot of console errors dublicate value found
here is screenshot
https://yadi.sk/i/5LSu3WGcwu9tT
Hi.
I worked through the tutorial, but in the result of the search function I had to write JSON.parse
The JSON object from Algolia came as a string.
Maybe I missed something.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.