vueact-stub
v0.1.3
Published
vue and react mixed programming stub module
Downloads
13
Maintainers
Readme
vueact-stub
install
npm install vueact-stub@^0.1.2 --save
api
- vueact.version
- print the module version
- vueact.createVueStub(appid)
- create a
VueStub
instance for react app
- create a
- vueact.createReactStub(appid)
- create a
ReactStub
instance for vue app
- create a
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>