vuera

2022-07-15

前端

微微怪时间不能保存情绪,保存那一切情绪所曾流连的境界。——《你是人间的四月天》

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

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

Use Vue components in your React app:

1
2
3
4
5
6
7
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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<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>

安装:

1
2
3
$ yarn add vuera
# or with npm:
$ npm i -S vuera

配置.babelrc

1
2
3
4
{
"presets": "react",
"plugins": ["vuera/babel"]
}