How to create a library that works with both Vue 2.7 and Vue 3?
P粉037880905
P粉037880905 2023-08-26 12:15:44
0
1
557
<p>First, there is the <code>vue-demi</code> library, which creates universal libraries for Vue 2 and Vue 3. </p> <p>But Evan You wrote this strange paragraph in the Vue 2.7 release notes: </p> <blockquote> <p>We would also like to express our appreciation for the community's previous efforts to bridge the gap before 2.7 became available: </p> <ul> <li>@vue/composition-api plug-in, author: @liximomo</li> <li>vue-demi, author: @antfu</li> <li>vite-plugin-vue2 by @underfin</li> </ul> </blockquote> <p>It sounds like <code>vue-demi</code> is no longer practical, is that true? </p> <p>If this is true, then why should I use <code>@vitejs/plugin-vue</code> in Vue 3 and <code>@vitejs/plugin-vue2< in Vue 2.7 /code> ? How to create a common library in this case? </p>
P粉037880905
P粉037880905

reply all(1)
P粉052686710

vue-demi Less necessary than before the 2.7 release, but if you want to create a truly universal library that can run on all versions of Vue 2, not just that, then it Still relevant to 2.7. Many users have not and will not upgrade from 2.6 to 2.7. Additionally, vue-demi still provides some additional compatibility features. From vue-demi Readme:

Regarding your question about @vitejs/plugin-vue and @vitejs/plugin-vue2, you seem to be confusing the Vite library with the Vue library. Vite provides the functionality to actually run and compile Vue, and since Vue 2 and Vue 3 run fundamentally differently, Vite would definitely require 2 different libraries to support each. If you are writing a library that can run in a Vue application, you may want to take advantage of vue-demi to ensure maximum compatibility.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template