[Vuejs]-VueJS convention and scope

0👍

You do not need either.
Vue will automatically take care of the scope and give the component a unique data-hash which then is taken to write your css. It really works well. Give it a try 😉

And your methods and computed properties are working just like normal. nothing to take care of.

0👍

For the first question, I think you should keep using class.
Although with the help of component-scoped CSS, you don’t need to worry much about the interference from other components’ stylesheets, all the templates will still be merged into one document. Vue.js just adds unique data attributes to the elements, it doesn’t guarantee every id’s uniqueness you defined.
So in order to keep flexibility and avoid potential troubles, it will be a wise choice to follow specifications of HTML which means keeping wrapper as a class if it appears in your HTML document several times.

For the second and third question, I prefer to keep the method names easy to read and understandable. All the JavaScript code will going to be minified and uglified, so there’s no need to add any prefix.

Leave a comment