Skip to content

Commit

Permalink
docs: add vue2 in vue3
Browse files Browse the repository at this point in the history
  • Loading branch information
doerme committed Oct 28, 2024
1 parent bfd31a2 commit e7fb22b
Show file tree
Hide file tree
Showing 13 changed files with 232 additions and 141 deletions.
6 changes: 6 additions & 0 deletions demos/vue3_2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
`demo`展示如何在`vue3`项目中使用`vue2`基站的远程组件

# 运行

在当前目录
```bash
pnpm i
pnpm dev
```

# 访问

http://localhost:9302/#/
1 change: 1 addition & 0 deletions demos/vue3_2/vue-2-base/emp.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default defineConfig(store => {
'./Table': './src/components/table',
'./CompositionApi': './src/components/CompositionApi',
'./store': './src/store',
'./Home': './src/views/Home',
},
empRuntime: {
runtimeLib: "https://unpkg.yy.com/@empjs/[email protected]/output/sdk.js",
Expand Down
2 changes: 1 addition & 1 deletion demos/vue3_2/vue-2-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@empjs/plugin-vue2": "3.2.0"
},
"dependencies": {
"@empjs/share": "3.2.0",
"@empjs/share": "3.3.1-beta.1",
"element-ui": "^2.15.14",
"vue": "^2.7.14",
"vue-router": "3",
Expand Down
6 changes: 1 addition & 5 deletions demos/vue3_2/vue-2-base/src/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import App from '@/App'
import store from '@/store'
import App from '@/views/Home'
import Vue from 'vue'
import router from './router'

new Vue({
router,
store,
render: h => h(App),
}).$mount('#emp-root')
4 changes: 2 additions & 2 deletions demos/vue3_2/vue-2-base/src/components/Content.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div>
<!-- <button class="button bigSize" @click="increment">Vuex Store : {{ $store.state.count }}</button> -->
<p @click="showMore">More... update from base</p>
<button @click="showMore">More... update from base</button>
<div class="more">
<ul v-if="isMore === true">
<li>
Expand All @@ -14,11 +14,11 @@
<li>
<h2>prop: {{ dataProps }}</h2>
<Button text-val="button components in content from import" />
<DynamicButton text-val="dynamic import" />
</li>
</ul>
</div>
<h2>JSX Dynamic Component</h2>
<DynamicButton text-val="dynamic import" />
<!-- <Hello /> -->
</div>
</template>
Expand Down
8 changes: 4 additions & 4 deletions demos/vue3_2/vue-2-base/src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
</ul>
<h2>Content Component</h2>
<Content />
<h2>Element Table</h2>
<Table />
<h2>CompositionApi</h2>
<CompositionApi />
<!-- <h2>Element Table</h2>
<Table /> -->
<!-- <h2>CompositionApi</h2>
<CompositionApi /> -->
</div>
</template>
<script>
Expand Down
13 changes: 5 additions & 8 deletions demos/vue3_2/vue-3-project/emp.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@ export default defineConfig(store => {
'@v2b': `vue2Base@${vue2Base}`,
},
empRuntime: {
runtimeLib: "https://unpkg.yy.com/@empjs/[email protected]/output/sdk.js",
frameworkLib: "https://unpkg.com/@empjs/[email protected]/dist",
// shareLib: {
// 'element-ui': [
// 'ELEMENT@https://unpkg.com/element-ui/lib/index.js',
// "https://unpkg.com/element-ui/lib/theme-chalk/index.css",
// ],
// },
runtimeLib: "https://unpkg.com/@empjs/[email protected]/output/sdk.js",
frameworkLib: "https://unpkg.com/@empjs/[email protected]/dist",
shareLib: {
'vue': 'Vue@https://unpkg.com/[email protected]/dist/vue.global.js'
},
framework: undefined,
},
}),
Expand Down
5 changes: 2 additions & 3 deletions demos/vue3_2/vue-3-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
"@empjs/plugin-vue3": "3.2.0"
},
"dependencies": {
"@empjs/share": "3.2.0",
"@empjs/share": "3.3.1-beta.1",
"ant-design-vue": "^4.1.2",
"vue": "^3.4.20",
"vue-router": "4"
"vue": "^3.4.20"
},
"scripts": {
"dev": "emp dev",
Expand Down
13 changes: 0 additions & 13 deletions demos/vue3_2/vue-3-project/src/App.vue

This file was deleted.

14 changes: 7 additions & 7 deletions demos/vue3_2/vue-3-project/src/Home.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<template>
<div>
<div @click="countData++">{{countData}}</div>
<h1>Vue 3 Project</h1>
<h2>=== @v2b/Content ===</h2>
<h2>vue2 Component: === @v2b/Content ===</h2>
<Vue2InVue3Adapter :mfComponent="() => import('@v2b/Content')" />
<h2>=== @v2b/compositionApi ===</h2>
<Vue2InVue3Adapter :mfComponent="() => import('@v2b/CompositionApi')" />

<div @click="countData++">{{countData}}</div>
<h2>vue2 Component: === @v2b/Home ===</h2>
<Vue2InVue3Adapter :mfComponent="() => import('@v2b/Home')" />
</div>
</template>

<script>
import {ref} from 'vue'
import Vue2InVue3Adapter, {vue2ToVue3} from './util'
import { vueAdapter } from '@empjs/share/adapter'
import vue, { ref } from 'vue'
const {Vue2InVue3Adapter} = vueAdapter
export default {
components: {
Vue2InVue3Adapter,
Expand Down
2 changes: 1 addition & 1 deletion demos/vue3_2/vue-3-project/src/bootstrap.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// import Antd from '@v3/Antd'
import {createApp} from 'vue'
import App from './App.vue'
import vue from 'vue'
import Home from './home.vue'
// console.log('Antd', Antd)
const app = createApp(Home)
Expand Down
90 changes: 0 additions & 90 deletions demos/vue3_2/vue-3-project/src/util.ts

This file was deleted.

Loading

0 comments on commit e7fb22b

Please sign in to comment.