且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

混合使用React和Vue是一个好主意吗?

更新时间:2023-11-28 08:35:52

如果主要原因是我已经知道Vue",那么我会拒绝.

如果他们已经知道Vue,那么应该很容易学会反应.

If they already know Vue it should be fairly easy to learn react.

我认为这两个框架可以一起工作,您可以在使用Vue构建的React应用程序中拥有一个小功能,因为即使您的SPA位于React中,Vue组件/应用程序也可以定位到任何html元素,并且可以这只是范围.

I think both frameworks can work together, you can have a small feature in your React app built with Vue because even though your SPA is in React, a Vue component/app can be targeted to any html element and have that to be it's only scope.

这种情况将是混合使用两种框架的好用例:

让我们说您已经拥有一个Vue应用程序,该应用程序可以计算出用不同大小的盒子装满卡车的***方式,它在逻辑和UI方面有些复杂,但实际上与应用程序中的其他逻辑隔离在那种情况下,我认为将Vue组件/应用程序嵌入到您的React SPA中会很好,因为您无需再次构建它.

Lets say you already have a Vue app that calculates the best way to fill a truck with boxes of different sizes and it's sort of complex in terms of logic and UI, but really isolated from the rest of the logic in your app in that case I think embedding a Vue component/app into your React SPA would be nice because you won't have to build it again.

如何限制Vue组件范围的示例:

<div id="app">
  {{ message }}
</div>

var app = new Vue({
  el: '#app',
  data: {
    message: 'Hello Vue!'
  }
})

在这种情况下,您将拥有仅渲染世界的Vue组件. https://vuejs.org/v2/guide/

In this case you will have a Vue component that only renders hello world. https://vuejs.org/v2/guide/