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

How to use vue.entend in components

coldplay.xixi
Release: 2020-12-23 17:33:37
Original
2546 people have browsed it

Usage: 1. Create a div container to place the component; 2. Create a child component; 3. Create a parent component; 4. Register entend through Vue.components; 5. Use "Vue.extend({ data: function () {return {}}})" statement.

How to use vue.entend in components

The operating environment of this tutorial: Windows 7 system, Vue version 2.9.6. This method is suitable for all brands of computers.

[Related article recommendations: vue.js]

Methods for using vue.entend in components:

1. extend creates a component constructor, not a specific component instance

So it cannot be used directly in new Vue:

new Vue({components: first})
Copy after login

In the end, it still has to pass Vue.components can only be used after registration.

Create a div container to place the component

How to use vue.entend in components

Create a sub-component

How to use vue.entend in components

Create a parent component

How to use vue.entend in components

Example writing method of local registration and global registration

How to use vue.entend in components

The result is:

How to use vue.entend in components

2. When instantiating the extends component constructor, the incoming attribute must be propsData, not props. In addition, the data definition in either Vue.extend or Vue.component must be a function return object, such as

Vue.extend({data: function () {return {}}})
Copy after login

In addition to new Vue, you can directly set objects to data, such as

new Vue({data: {}});
Copy after login

How to use vue.entend in components

The above is the detailed content of How to use vue.entend in 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