Home > Web Front-end > Vue.js > body text

How to introduce components in vue.js

王林
Release: 2020-11-19 09:57:08
Original
8882 people have browsed it

How to introduce components in vue.js: 1. Create a folder for custom components; 2. Add the module to be introduced to the page to be added; 3. Introduce the module into index.vue; 4. , just introduce the component on the index.vue page.

How to introduce components in vue.js

The specific steps are as follows:

(Related video recommendations: jquery video tutorial)

1 , First create a folder specifically for placing custom components in your project (I placed it in common under components, this article uses table.vue as an example)

How to introduce components in vue.js

2. Then add the module to be introduced to the page you want to add, paying attention to the camel case naming method (for this article, for example: , because when I define the table module It is to define name: v-table, so when citing, you must also use the name defined in the table module);

How to introduce components in vue.js

3. Then in index.vue Introduce the table.vue module

//index.vue 页面 ,引入v-table模块
//这就是你引入的自定义模块;注意是驼峰命名法
Copy after login

4. Introduce this component on the index.vue page (note: table.vue, I added the module to the index.vue page, not the html tag , in fact, vue introduces new sub-components)

//index.vue
Copy after login

Tips: To put it bluntly, custom components are like encapsulation, extracting some public modules and then writing them into separate tool components or pages. When needed, custom components are like encapsulation. Just import it directly into the page.

In addition, in order to prevent writing too much code on the same page and inconvenience later maintenance, the entire page can be divided into multiple small modules, and then the modules can be introduced on the main page, and the creation includes the introduction The steps are all the same.

For example:

How to introduce components in vue.js

Related recommendations: vue.js tutorial

The above is the detailed content of How to introduce components in vue.js. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!