4 ms·
Vue is awesome. The encapsulation that comes from single file components is something I would love to have in React.
by onion2k 6y ago
Vue is awesome. The encapsulation that comes from single file components is something I would love to have in React.
- siquick 6y agoWhat’s to stop you using single file components in React? Having everything in one file was the thing I didn’t like about Vue - constantly scrolling up and down the file between the methods and the template/styling got pretty annoying quickly.
- Semaphor 6y ago> What’s to stop you using single file components in React? Probably the same thing that stopped you from not using SFCs in Vue: One is idiomatic, the other isn’t ;)
- onion2k 6y agoWhat’s to stop you using single file components in React? The only way I know of to make them is to use styled components. RedwoodJS seems to doing something like a template literal for styling but that's still not really the same. In my opinion Vue's <style scoped> approach is much more elegant. constantly scrolling up and down the file between the methods and the template/styling got pretty annoying quickly Buy a bigger monitor. :)
- petepete 6y agoThat's my least favourite thing about Vue. One directory per component makes so much more sense to me, not having a mix of syntaxes in a single file. Still, Vue is my favourite tech for SPAs.
- manigandham 6y agoVue (like with most of its features) let's you do that if you want. The <script> and <style> tags in the .vue file can reference other files so you can have a directory per component with separate code files. Sometimes that's helpful for better code completion and formatting too.
- jtwaleson 6y agoI really love single file components. We are extending the syntax more by also adding <specification> and <requirements> tags to single file components. Great for automatically generating documentation and keeping it in the same place as the components. Was a bit afraid that the compiler would protest, but so far so good.
- buzzwordninja 6y agoWhere do you put the elements? Next to the <template> or inside it?
- jtwaleson 6y agoNext to it, so that it doesn't interfere with either <style>, <script> or <template>.
- rk06 6y agoVue does allow you to split css, js and html to separate files by using src attribute in sfc file. Ref: https://vuejs.org/v2/guide/single-file-components.html#What-About-Separation-of-Concerns https://vuejs.org/v2/guide/single-file-components.html#What-...