vuera

2022-08-21 14:39:23 浏览数 (1)

分享一个开源项目:https://github.com/akxcv/vuera

它可以让你在vue里写react,在react里写vue

Use Vue components in your React app:

代码语言:javascript复制
import React from 'react'
import MyVueComponent from './MyVueComponent.vue'

export default props =>
  <div>
    <MyVueComponent message={props.message} handleReset={props.handleReset} />
  </div>

Or use React components in your Vue app:

代码语言:javascript复制
<template>
  <div>
    <my-react-component :message="message" @reset="reset" />
  </div>
</template>

<script>
  import MyReactComponent from './MyReactComponent'

  export default {
    /* data, methods, etc */
    components: { 'my-react-component': MyReactComponent },
  }
</script>

安装:

代码语言:javascript复制
$ yarn add vuera
# or with npm:
$ npm i -S vuera

配置.babelrc

代码语言:javascript复制
{
  "presets": "react",
  "plugins": ["vuera/babel"]
}

0 人点赞