Home  >  Article  >  Web Front-end  >  Configuration and use of vue-cli components

Configuration and use of vue-cli components

php中世界最好的语言
php中世界最好的语言Original
2018-04-28 15:29:032062browse

This time I will bring you the configuration and use of the vue-cli component. What are the precautions for the configuration and use of the vue-cli component. The following is a practical case, let's take a look.

Overview:

A file is a module, the module needs to be introduced, and the method of exposing the module

Using another component in one component is a trilogy: introducing the component, Registering components and using components

1.Interpretation of the main.js file

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

2, The use of components

. The defined components are generally placed in the components directory
. The process of using a component

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 introduced), 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 self-defined file, you must write the relative path './'
. If you introduce node--you do not need to write the file under modules

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 you want the object to have content, XX needs 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:

How to remove duplicate data when merging multiple arrays

What is required for vue configuration to request local json data step

The above is the detailed content of Configuration and use of vue-cli components. 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
Previous article:How to install vue on MacNext article:How to install vue on Mac