Home > Web Front-end > JS Tutorial > body text

How to import and use vue-cli components

php中世界最好的语言
Release: 2018-05-25 14:03:44
Original
1686 people have browsed it

This time I will show you how to implement the import and use of vue-cli components, and what are the precautions for implementing the import and use of vue-cli components. The following is a practical case, let's take a look.

A file is a module, you need to introduce the module, and the method of exposing the module

The three steps of using another component in one component: introducing the component, registering the component, and using the component

1.main.js file interpretation

. It is the entry file of the entire project.
.import (es6) in the src folder introduces vue and the root component app. vue
. Finally new Vue, start the application

2, use of components

. The defined components are generally placed in Under the components directory
. Use a component process

a. The referenced file exposes the object (if there is no script in the component, there is no need to expose it)

b. The parent component introduces the child component, registers the component (global components do not need to be imported), and uses the component

to extend: import

import OO from XX

1.import is equivalent to var and let to declare a variable OO (customization, destructuring and assignment are both possible)

2.from: which file to import

.If It is a file defined by yourself. You must write the relative path './'
. If you introduce node--modules files do not need to write

import variable from ' Module path
import {destructuring assignment} from 'module path
import {* as variable} from 'module path

3. At this time OO returns an object

4.If If you hope that there is content in the object, you need XX to expose the object first, so that OO can receive it and use it in the current file. According to the format of the exposed object, decide the format of the variable

. Expose multiple objects and receive them through destructuring assignment

. Expose multiple objects and pass a Variable reception

# I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the PHP Chinese website!

Recommended reading:

Detailed explanation of the steps for using antd drop-down box linkage

How to use JS to merge multiple arrays and remove duplicates Calculate

The above is the detailed content of How to import and use vue-cli components. 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!