Chapters
48 Chapters
|
5:05:52
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!
Subscribe to download the code!
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Subtitles
Subscribe to download the subtitles!
Subscribe to download the subtitles!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
30.
Passing data From the Server to Vue
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
This course is also built to work with Vue 3!
What JavaScript libraries does this tutorial use?
// package.json
{
"devDependencies": {
"@symfony/webpack-encore": "^0.30.0", // 0.30.2
"axios": "^0.19.2", // 0.19.2
"bootstrap": "^4.4.1", // 4.5.0
"core-js": "^3.0.0", // 3.6.5
"eslint": "^6.7.2", // 6.8.0
"eslint-config-airbnb-base": "^14.0.0", // 14.1.0
"eslint-plugin-import": "^2.19.1", // 2.20.2
"eslint-plugin-vue": "^6.0.1", // 6.2.2
"regenerator-runtime": "^0.13.2", // 0.13.5
"sass": "^1.29.0", // 1.29.0
"sass-loader": "^8.0.0", // 8.0.2
"vue": "^2.6.11", // 2.6.11
"vue-loader": "^15.9.1", // 15.9.2
"vue-template-compiler": "^2.6.11", // 2.6.11
"webpack-notifier": "^1.6.0" // 1.8.0
}
}
8 Comments
If are building a similar app from scratch then you will need
composer require sensio/framework-extra-bundle
or your link /category/id will not work you will get "service not exists error" <3
Hey Numan A.
Yes, you're right. That bundle is required if you want to leverage the ParamConverter feature on your routes. Thanks for pointing it out
Cheers!
I'm noticing (in the video) the dreaded Flash Of Unstyled Content, a/k/a FOUC. What's causing that and how to we fix it? (I know in general terms it happens when the HTML is rendered before the CSS and Javascript do their thing, but I'm wondering what's going on in this specific case.)
Hey David,
I'm not sure I understand, are you referring to the specific point in timeline of the video?
Cheers!
The first FOUC comes at about 0:17.
Hey, Ryan!
I think your solution with global variable is ugly.
I used HTML data attribute<a href="https://ibb.co/nswZj3z"> for server vars.</a>
What do you think about it?
// assets/js/products.js
import { createApp } from 'vue';
import App from '@/pages/products';
const mountEl = document.querySelector('#app');
createApp(App, { ...mountEl.dataset }).mount('#app');
Hey Evgeniy,
I don't think that's ugly, it's still a valid case. But yes, there's another way you can pass data to your JS code using data attributes, and this is also good. And I bet we also mention this way in our tutorials, maybe not in this one, but in others - definitely. Feel free to use any of these solutions. But from the performance point of view, using global vars might be more effective, though I'm not sure 100%.
Cheers!
"Houston: no signs of life"
Start the conversation!