How to learn Vue front-end framework? In fact, vue.js is defined as a “data-driven progressive” framework, and many of the things that make it easy to learn, such as two-way data binding, modular component routing, flexible instructions, buckets and so on.
Soul Torture one: “What is the essence of Vue2? Why do so many companies use it in their business?”
“For obvious reasons, isn’t Vue2 a data-driven incremental framework? Data driven you don’t understand? Progressive you don’t understand? You don’t know how to use a bucket?” Yes, if I had fought back like this! But, actually, today I’m going to give you another answer, and you guys are going to judge. What’s the difference between these two answers?
First, I want to say that Vue is essentially a “constructor” (factory function? Constructor? Don’t understand? Poor foundations shake the earth, little friends!) . When we instantiate a Vue object using the new keyword (what does the new keyword do in the constructor? Don’t know? Why do so many interview questions ask this question? , the prototype, properties and methods declared on the prototype chain are based on object-oriented programming ideas (OOP). Oh, my God, go learn the basics! All of our operations are essentially operating on property changes and method calls to this object.
Why is my first question about this Vue instance object? First of all, the powerful Vue, the authors design the novel full of, many beginners of it will instinctively feel like and native doesn’t make much difference whether JavaScript, actually otherwise, its essence is still a factory constructor instantiation of objects, is merely a massive object, it is the accumulation of n personal wisdom crystallization. It is rich in a lot of programming thinking and solid theoretical foundation, which is the ultimate path of our front-end engineer technology direction: core architect. However, to grow to this point, people need not only learning, but also a team atmosphere with scientific research environment.
Soul Torture ii: Why Vue3? Where should Vue3 be used in the enterprise? Where should I not use it?
Before I answer this question, LET me mention two key words that come up a lot in our basic programmer classes: cohesion and coupling! This is the programming specification, high cohesion, low coupling! Why Vue3? In fact, essentially speaking is to solve this problem! So the question is, where is the cohesion of Vue2 low? Where is the coupling higher? Of course, I don’t want to mention the Composition API or Options API. In fact, I already did! In fact, even before the Vue3 source code was published, Vue officials had already revealed the new way Vue3, which represents the next generation of Vue technology, would use the interface. This new approach is called Composition API. The corresponding classical API is also known as the Options API or option-based API.
In the classic Options API, we use a JS object with “Options” such as data and methods to define a page or component. This simple and direct approach is very user-friendly in the early stages of application, when the code and business logic are relatively simple, which is also a factor that Vue has a low learning threshold and is widely embraced by developers.
However, developers who have developed large Vue applications should know this. As pages become more logical, our components become long and complex. There’s a lot of logic and code that you can reuse that you can’t reuse in a very comfortable way. For example, in Vue2, the most common way to reuse component logic and code is to mix mixins. This is a viable approach, but it is clearly tightly coupled to the Vue framework from birth (see? Is that high coupling? Anti-programming basic specification! . When you try to reuse a frame-neutral generic JS function or object into a component developed in Vue2, you find that everything is very inelegant. Driven by the need to reuse existing code more elegantly in developing large Vue applications, the Vue3 Composition API seems to be a natural and inevitable choice.
TypeScript is great. How much do you use it in your projects? Do you think it should be used?
TypeScript is essentially designed to solve the problem of weak typing in the JavaScript programming language, and to effectively solve the problem of sloppy application variables passing from one program to another. Procedures, must be very strict ah! After all, JavaScript is the hot language right now. So how does TypeScript solve this serious problem? It’s official: TypeScript essentially adds “optional static typing” and “class-based object-oriented” programming to the JavaScript language, and it’s a superset of JavaScript.
To be honest, the TypeScript documentation is very, very good for front-end developers to learn and use. It’s a great way to break through our technical barriers, and I encourage you to read it carefully.
Finally, let’s talk about using TS in the project, buddy! Small projects, not complex projects, really can not use! What’s the point with all this insides? ! Just for the simplest type constraint, show some new syntactic features, do some generic programming, and how much work does Node’s Webpack have to do to parse your stuff? How much more code? Really, unless it is the data rigorous requirements are extremely high, the project business logic is extremely complex project, can not volume do not volume!
Soul torture four: if a project, how do you accurately judge you should use Vue2? Or Vue3? Or React? Or jQuery? Or even native JavaScript?
See mountain is mountain, see water is water! The affectation of a man without heavy make-up or monkey face! More not, do not understand pretend to understand, self-deceiving foolhardiness! Technology is always a compromise solution for business, it’s true! Since it is a compromise solution, the core lies in the pros and cons weigh up! If the site is strongly associated with SEO and the front and back ends are hard to separate, you have to use something Vue or React, that is not right! JQuery DOM based programming is definitely your best choice!
Use Vue3 or React Hooks if you have a large complex project with a large number of business module reuse logic and complex data communication logic, then you can use Vue3 or React Hooks. The cost of communication alone will drive you crazy!
Native JavaScript? Ok, if you are involved in the latest cutting-edge topics, such as blockchain client logic encapsulation, or you in dachang a framework research center, you can use, small, or be careful! Do you really think native JavaScript is easy? Did not really get through the ability of ren Du two veins, go astray is often the thing!
Have I learned the Vue front-end framework yet? No! I’m just getting started! Thousands of words, in fact, I want to say to my friends is such four words: “lay a good foundation”. How to lay a good foundation? Assembly principles, network engineering, data structures, basic algorithms, development patterns, etc., these seemingly useless university books will have the answers you need!