分享一个开源项目: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
{
"presets": "react",
"plugins": ["vuera/babel"]
}