update structure
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
<template>
|
||||
<div class="container mx-auto p-4">
|
||||
<h1 class="text-2xl font-bold mb-4">Nuxt 3 MFE Remote App</h1>
|
||||
<RemoteComponent />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,27 @@
|
||||
<template>
|
||||
<div>
|
||||
<component v-if="asyncPageComponent" :is="asyncPageComponent" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { defineAsyncComponent } from "vue"
|
||||
|
||||
/**
|
||||
* @todo
|
||||
* it'll be nice if there is a way to dynamically match route and render..
|
||||
*/
|
||||
console.log(">>", window.location.pathname)
|
||||
|
||||
const Index = defineAsyncComponent(() => import("@/pages/contact/index.vue"))
|
||||
const Properties = defineAsyncComponent(() =>
|
||||
import("@/pages/contact/properties.vue")
|
||||
)
|
||||
|
||||
let asyncPageComponent
|
||||
if (/\/contact\/properties/.test(window.location.pathname)) {
|
||||
asyncPageComponent = Properties
|
||||
} else {
|
||||
asyncPageComponent = Index
|
||||
}
|
||||
</script>
|
||||
@@ -1,22 +0,0 @@
|
||||
<template>
|
||||
<div class="p-4 border rounded bg-blue-50 sty1">
|
||||
<h2 class="text-xl mb-2">Remote Component</h2>
|
||||
<p>This component is exposed from the remote application</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
defineComponent({
|
||||
name: 'RemoteComponent'
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
console.log('mounted')
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.sty1 {
|
||||
background: pink;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
Remote layout
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -11,7 +11,7 @@ export default defineNuxtConfig({
|
||||
name: "remote-app",
|
||||
filename: "remoteEntry.js",
|
||||
exposes: {
|
||||
"./RemoteComponent": "./components/RemoteComponent.vue"
|
||||
"./ContactRouter": "./components/ContactRouter.vue"
|
||||
},
|
||||
shared: []
|
||||
// shared: ['vue']
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@
|
||||
"preview": "nuxt preview",
|
||||
"postinstall": "nuxt prepare",
|
||||
"clean": "rimraf .output",
|
||||
"serve": "serve .output/public -p 3001"
|
||||
"serve": "serve .output/public -p 3001 --cors"
|
||||
},
|
||||
"dependencies": {
|
||||
"nuxt": "^3.13.0",
|
||||
@@ -21,4 +21,4 @@
|
||||
"rimraf": "6",
|
||||
"@originjs/vite-plugin-federation": "^1.3.5"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<template><div>about rmt</div></template>
|
||||
@@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<div class="rmt">
|
||||
<h1>rmt/pages/contact/index.vue</h1>
|
||||
<div>Contact index</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup></script>
|
||||
<style scoped>
|
||||
.rmt {
|
||||
background-color: antiquewhite;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,11 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1>rmt/pages/contact/properties.vue</h1>
|
||||
<div>Contact prop</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
definePageMeta({
|
||||
name: "contact1"
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
// import ContactRouter from "~/components/ContactRouter.vue"
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="container mx-auto p-4">
|
||||
<h1 class="text-2xl font-bold mb-4">Nuxt 3 MFE Remote App</h1>
|
||||
<!-- <ContactRouter /> -->
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user