在 React 中运行 Vue react-vue

码农软件 · 软件分类 · Vue 组件 · 2019-03-20 10:26:37

软件介绍

React-Vue旨在连接 React 和 Vue,帮助您在 React 中运行 Vue。

用途:

  • 使用Vue 的 Reactivity 系统来观察React组件

  • 使用 react-vue-loader 以在React应用中运行Vue组件

Reactivity 系统

感谢 Vue 层次分明的简洁设计,我们可以很容易的将 reactivity 系统导出(9KB压缩包),并在其上驱动 React 组件

npm install --save react-vue
import React, { Component } from 'react';import Vue, { observer } from 'react-vue';const store = new Vue({  data () {    return {
      count: 0
    }
  },
  methods: {    increase () {      this.count ++;
    }
  }
});

@observerexport default class Demo extends Component {  render () {    return <h1 onClick={store.increase}>{store.count}</h1>;
  }
}

文档

Vue组件

引入react-vue-loader 可以将Vue组件编译成一个React组件。正如您所想的那样,您编写的Vue组件可以在React组件中运行,React组件也可以在Vue组件中运行。

npm install --save react-vue react-vue-helper
npm install --save-dev react-vue-loader
// One.jsimport React, { Component } from 'react';import Two from './Two';export default class One extends Component {  render() {    return <Two>Hello Vue</Two>;
  }
}
<!-- Two.vue --><template>
  <div @click="count++">
    <three>{{count}}</three>
    <slot></slot>
  </div>
</template>

<script>  import Three from './Three'  export default {    components: { Three },    data () {      return {        count: 0      }    }  }</script>
// Three.jsimport React, { Component } from 'react';export default class Three extends Component {  render () {    return <span>{this.props.children}</span>
  }
}

文档

本文地址:https://codercto.com/soft/d/1749.html

Web标准设计

Web标准设计

刘杰(嗷嗷) / 清华大学出版社 / 2009-1 / 75.00元

一扇经常开启的门的铰链不需要润滑油。 一条湍急的河流不会变得污浊。 无论是声音还是想法都不可能在真空中传播。 Web标准如果不用就会腐朽。 这世界真奇妙! 专题页面:http://www.aoao.org.cn/book/web-standards-design/一起来看看 《Web标准设计》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码