I want to use vue to reconstruct an old project written in jq, how should I start?
代言2017-07-05 11:03:14
jquery
is just a library, and vue
is a framework. The decision to use vue
to refactor means that you must use its writing method to write the project.
Although vue
and jquery
are not mutually exclusive in themselves, I have also used jquery
in vue
, but it is limited to some special scenarios. The entire project is still based on vue
.
So, if you want to use vue
to reconstruct an old project, the HTML part may not change much, but the business code logic basically needs to be completely overturned and redesigned.
女神的闺蜜爱上我2017-07-05 11:03:14
vue only supports browsers above IE9, jQuery can support IE6, please pay attention to whether there is a browser version requirement
欧阳克2017-07-05 11:03:14
If you have implemented a similar simple framework, you will find that the essential difference between Vue and jQuery lies in the different ways of organizing UI logic.
jQuery is purely a collection of syntactic sugar for the original DOM API, while Vue is a framework that emphasizes the separation of [HTML template] and [UI interaction] logic through the organizational form of MVVM (not MVC!). MVVM's data binding syntax makes it so that when Vue is introduced into an old project, its (actually much more advanced) code organization will strongly exclude jQuery (in other words, there is basically no need to use jQuery in projects that use Vue) , coexistence of both is not a good choice).
At this time, a solution that is conducive to improving efficiency without being too radical is to introduce a [simple MVC framework that can optimize the jQuery noodle code organization structure]. This framework does not have the syntax that comes with VM frameworks, and the corresponding logic is still Need to be implemented using jQuery. At the same time, this type of framework is also much lighter than Vue. For example, Backbone is only 10k in size. It is recommended to gradually introduce it as an optimization solution in old projects.
我想大声告诉你2017-07-05 11:03:14
Partial reconstruction, partial module or partial plug-in reconstruction, to ensure the normal operation of the project, partially replace jQuery
vue