I've been learning Vue myself and am a little confused by the fact why no one is using separate JS files and just includes everything with tags. Or was that just for the purpose of the tutorial?
I'm a dev with a strong *NIX sysadmin background. I've been programming for 20+ years, started with IRC scripts, C, Python, PHP, Ruby/Rails, Node/JS, Go and Elxir. Full time on Ruby,Elixir and Rust.
I'm using Vue since 2 years now. The single file component is very useful to wrap all the specific things you need for a component in a single place.
Of course you'll surely have a main CSS/JS library/framework/whatever (Bootstrap, Bulma, ...) for the generic things, but when you need some specific piece of CSS to style a component it's a lot better to put it in the single Vue file.
Last but not least, the main editors out there all have at least one plugin to handle single-file Vue components correctly (mainly it's all about syntax highlighting)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Awesome article!
I've been learning Vue myself and am a little confused by the fact why no one is using separate JS files and just includes everything with tags. Or was that just for the purpose of the tutorial?
I don't think it's everyone. It depends on preference but it seems Vue is more of the opinion of having them in one file.
You can read about it here: vuejs.org/v2/guide/single-file-com...
I'm using Vue since 2 years now. The single file component is very useful to wrap all the specific things you need for a component in a single place.
Of course you'll surely have a main CSS/JS library/framework/whatever (Bootstrap, Bulma, ...) for the generic things, but when you need some specific piece of CSS to style a component it's a lot better to put it in the single Vue file.
Last but not least, the main editors out there all have at least one plugin to handle single-file Vue components correctly (mainly it's all about syntax highlighting)