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!
09.
v-bind: Dynamic Attributes
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
}
}
3 Comments
Nice tutorial again! How can i add a static image to a template in vue? I tried a few options, one is :src="'/static/img/clear.gif'". But no succes.
Hey lexhartman!
Excellent question! There are 2 things to know.
1) In theory, it should be this simple:
Where you literally just use the relative path to the image file. So in this example, my loading.gif is "up" 2 directories, then inside an images/ directory (relative to the component where I wrote this code).
2) But... there's a pretty good chance that when you try this, you will end up with
src="[object Module]". This is due to some internal options in Encore... it's confusing - here is some info on it https://github.com/vuejs/vue-loader/issues/1612The best way to fix this is to make it dynamic:
Then in your component:
That's it! A bit of an annoying extra step, due to how file-loader and the Vue compiler aren't playing nicely together, but it should get you what you need :).
Cheers!
The first solution indeed ended up with
src="[object Module]". After making it dynamic it worked. So thanks!"Houston: no signs of life"
Start the conversation!