0.1.3 • Published 2 years ago

vueact-stub v0.1.3

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

vueact-stub

install

npm install vueact-stub@^0.1.2 --save

api

  1. vueact.version
    • print the module version
  2. vueact.createVueStub(appid)
    • create a VueStub instance for react app
  3. vueact.createReactStub(appid)
    • create a ReactStub instance for vue app

demo

<script>
    window.config = {
        "apps": [
            {
                "id": "appid",
                "cdnBase2": "http://127.0.0.1:7001",
                "files": [
                    "{cdnBase2}js/chunk-vendors.js",
                    "{cdnBase2}/js/app.js"
                ]
            }
        ]
    };
</script>
<script src="<%-cdnBase%>/libs/vueact-stub/0.1.2/dist/vueact-stub.min.js"></script>
// webpack.config.js
module.exports = {
    externals: {
        'vueact-stub': 'VueactStub'
    }
};

react用法

import React from 'react';
import ReactDOM from 'react-dom';
import vueact from 'vueact-stub';

const VueStub = vueact.createVueStub('appid');
const Test = ReactStub.wrap('Test');

ReactDOM.render(<Test
    content="react test"
    onClick={ev => { console.log(ev); }}
/>, document.querySelector('#app'));

vue用法

<template>
    <Test content="vue test" @click="handleClick" />
</template>
<script>
import vueact from 'vueact-stub';

const ReactStub = vueact.createReactStub('appid');
const Test = ReactStub.wrap('Test');

export default {
    components: {
        Test
    },
    methods: {
        handleClick(ev) {
            console.error('react click event:', ev);
        }
    }
};
</script>