My github address -vue3.0Study- The learning results of stages will be branched.
Q&A
1. What are the vue components?
Why add vue? Because different MVC frameworks have different things, but they all have basic functions.
Components include data, computed, watch, methods, and life cycle hooks. For beginners, figure out what these are first.
After studying the data attributes in the previous articles, we have a preliminary understanding of them.
computed is a computed property, which I also understand before.
The methods component method is actually an object that specifically defines functions, and these functions are ultimately bound to the component.
Watch and Lifecycle Hook are not advanced things either! It's just a function, don't be scared by these [high-end] names. I'll learn them later. If you have understood the concept of function overloading in C++ or JAVA, then you can understand these two things like this.
2. What are components?
Components are not something profound. html tag div form img, etc., it is all [components], but the components in vue can be named by themselves, or they can define their own attributes, etc. To put it bluntly, it is the extension tag.
Regarding components, the standard has actually been implemented, called [custom elements]. Google has made a polyfill for browsers that do not implement this standard, that is, the [polymer] framework: the polymer address, which has been released to version 3.0, and Google has been maintaining it.
3. What else should I know about the components?
Component reuse, component registration, component organization, how components pass data to each other, component slots, dynamic components, etc.
Component reuse is actually to make it into an html [tag]. How to use it, what data it passes to it, what interactive functions it has, and how it displays (the previous articles are introducing these) are all predefined.
Component registration and component organization are understood in combination. Or use html to understand, div can contain div (sub-element); components can also contain sub-components; how html is organized, and how components are organized; what is registration? If a component in vue wants to use other components, it must import other components, and this is registration. right! Registration and organization are that simple!
Registration also includes global registration and local registration. We will introduce it slowly in the future.
Pass data. The data cannot be transmitted by itself between html tags (of course, some css attributes such as font-size are passed in one direction). The vue component can be different. The parent component can not only pass data to the child component, but also pass data to the parent component. Parent => use props for the child; child => use emit event for the parent.
Slot. I don’t think it is necessary to use it in the actual application process, and I will introduce it in the future.
Dynamic components. For example, the nav navigation bar, each navigation can be understood as a single component, and after component reuse, it is the navigation bar. So how do you know which navigation is currently? This is what dynamic components are used for.
What components need to know, this is a brief introduction.
Something higher-end
As mentioned above, the data flow of components, dynamic and asynchronous components, special ways to access components, dependency injection, forced updates, etc. When learning routing, the entangled relationship between components and routing, the relationship between state management systems and components, etc., I won’t say that so many things are scary. In fact, these things are not profound things. In the future, I will introduce them in an image way.
Okay, the above is all the content of this article. I hope it will be helpful to everyone. If you have any questions, please leave me a message. The editor will reply to everyone in time!