react組件集成到vue框架(Vuera的使用)


最近項目中有需要把react組件集成到vue框架中,自己研究了一下,最終實現了。有人會比較好奇為什么要這么做,主要是因為項目工期比較趕,如果自己開發這個功能最少需要半年的時間,所以找了三方組件集成進來,最后調研的組件中最符合業務需求的組件是使用react寫的。

首先是調研了一下網上的解決方案,最后定下來使用Vuera三方插件來集成react,直接上代碼:

 

 1 <template>
 2 <div id="root">
 3   <component :is="videoPlayer" ></component>
 4 </div>
 5 </template>
 6 <script>
 7 import { ReactInVue } from 'vuera';
 8 import AnnotationPageContainer from './cvat-ui/containers/annotation-page/annotation-page';//react組件所在的開始頁面
 9 
10 export default {
11     components: { player: ReactInVue(AnnotationPageContainer)},
12     data () {
13         return{
14           videoPlayer: "player",
15         }
16     },
17 }
18 <script>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM