Home  >  Article  >  Web Front-end  >  What to put in the views directory in vue

What to put in the views directory in vue

WBOY
WBOYOriginal
2022-04-08 16:31:588309browse

The views directory in vue contains page-level components, which are various pages that have been written, also called page directories; the page components located in the views directory will be used by at least one route, and can be used by Components accessed by routing are moved to the views directory.

What to put in the views directory in vue

The operating environment of this article: Windows 10 system, Vue version 2.9.6, DELL G3 computer.

What to put in the views directory in vue

views is the page directory

src/views: used to store various pages we have written, such as login, main, etc.

view1.vue page-level component is placed in the views directory. If there are sub-components, you can create a subdirectory

Expand knowledge:

Two directories Both src/components and src/views contain Vue components.

The key difference is that some Vue components play the role of views in routing.

Vue Router is usually used to process Vue routing. Routing is to switch the current view of the component. These routes are usually placed in src/router/routes.js, where we can see the following content:

What to put in the views directory in vue

  • public: used to store static File

  • public/index.html: is a template file, which is used to generate the entry file of the project. The js and css packaged by webpack will also be automatically injected into the page. When our browser accesses the project, it will open the generated index.html by default

  • src: where we store various vue files

  • src/assets: Used to store various static files, such as pictures, etc.

  • src/components: Used to store our public components, such as header, footer, etc.

  • src/views: used to store various pages we have written, such as login, main, etc.

  • src/APP.VUE: The main vue module introduces other Module, app.vue is the main component of the project, all pages are switched under app.vue

  • src/main.js: Entry file, the main function is to initialize the vue instance. At the same time, you can reference some component libraries in this file or hang some variables globally

  • src/router.js: Routing file, which can be understood as the address path of each page, use For our access, we can also write routing guards directly in it

  • src/store.js: Mainly used to save some states in the project, save the state in state, and write it in mutations For modifying the state in the state, actions have not been put into practice for the time being. I don’t know how to use them

  • package.json: Basic module information module, version, project name required for project development

[Related recommendations: "vue.js Tutorial"]

The above is the detailed content of What to put in the views directory in vue. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn