Chapters
44 Chapters
|
4:19:56
|
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!
38.
v-model on a Custom Component
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": {
"@fortawesome/fontawesome-free": "^5.15.1", // 5.15.1
"@symfony/webpack-encore": "^0.30.0", // 0.30.2
"axios": "^0.19.2", // 0.19.2
"bootstrap": "^4.4.1", // 4.5.3
"core-js": "^3.0.0", // 3.6.5
"eslint": "^6.7.2", // 6.8.0
"eslint-config-airbnb-base": "^14.0.0", // 14.2.0
"eslint-plugin-import": "^2.19.1", // 2.22.1
"eslint-plugin-vue": "^6.0.1", // 6.2.2
"regenerator-runtime": "^0.13.2", // 0.13.7
"sass": "^1.29.0", // 1.29.0
"sass-loader": "^8.0.0", // 8.0.2
"vue": "^2.6.11", // 2.6.12
"vue-loader": "^15.9.1", // 15.9.4
"vue-template-compiler": "^2.6.11", // 2.6.12
"webpack-notifier": "^1.6.0" // 1.8.0
}
}
4 Comments
Hi ,
For Vue 3 it does not work:
@input="$emit('input', $event.target.value)"and@input="form.customerName = $event"As I understand,
"input"- reserved. On parent we got Event vs String.I fixed by event rename:
May be It's wrong solution?
BR.
Ruslan.
Hey Ruslan,
Yes, you're right, in Vue 3, the
v-modelcontract changed and now it's:Instead of how it was in Vue 2:
So your workaround isn’t "wrong", it’s just a custom event scheme. It just means you use your own contract instead of using Vue’s
v-modelconvention. That’s fine if you like it, but it means your component won’t work with v-model syntax out-of-the-box. Otherwise, look at the v-model example for Vue 3.I hope this helps!
Cheers!
Heyho ! Seems there's a little error in vue 2 v-model explanation at the solution popup of chapter 38 challenge ? Shouldn't it be @input="client.name=$event" instead of @input="$emit('input', $event.target.value)", because it's the outer component in that context ?
Hey DocLommy,
You're right, we display incorrect code block in that part, I just fixed it, the new code block is: https://symfonycasts.com/sc...
Thank you for reporting this!
Cheers!
"Houston: no signs of life"
Start the conversation!