亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Translation of schema and file distribution issues in VueJS projects
P粉015402013
P粉015402013 2023-09-14 20:40:49
0
1
592

I started learning VueJS and I realized that a typical .vue file consists of three different parts, which are <template>, <script> and <style>.

My question is about how to handle these three parts in a real professional project with VueJs. From my understanding they should be separated into three different parts.

For example, I would tend to separate them in the following folders:

Under the src folder, I will create the following subfolders:

src
 ->script(JavaScript函數(shù)將在這里定義)
    index.js 
 ->style(樣式內(nèi)容將在這里定義)
    index.css
 ->pages(模板內(nèi)容將在這里定義)
    index.vue

Is this handled in real medium- to large-scale VueJS projects? If not, why? What are the pros and cons of this approach?

Thank you in advance for your answers!

best regards,

Paul

P粉015402013
P粉015402013

reply all(1)
P粉617597173

Good tip, about reading the documentation. I didn't find it. According to https://vuejs.org/guide/scaling-up/sfc.html#what-about-separation-of-concerns:

Some users who come from traditional web development backgrounds may worry that SFC mixes different concerns in the same place - which HTML/CSS/JS should be separated from!

To answer this question, we need to reach a consensus that separation of concerns is not equivalent to separation of file types. The ultimate goal of engineering principles is to improve the maintainability of your code base. Applying the separation of concerns rigidly to the separation of file types does not help us achieve this goal in an increasingly complex front-end application environment.

In modern UI development, we find that instead of dividing the code base into three huge intertwined layers, it makes more sense to divide it into loosely coupled components and combine them. Within a component, its templates, logic, and styles are inherently coupled, and putting them together actually makes the component more cohesive and maintainable.

Even if you don’t like the idea of ??single-file components, you can still use Src Imports to apply its hot reload and precompilation features to your project by separating JavaScript and CSS.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template