Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings
vuejs

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Nested components in template generated by PHP.#14204

Unanswered
mrFANRA asked this question inHelp/Questions
Discussion options

Hi!

I have template rendered by php:

<div>    <h1>Im header</h1>    <div is="vue:testcomponent">        <div is="vue:othercomponent"></div>    </div></div>

With that Vue code all working fine:

import { createApp } from 'vue/dist/vue.esm-bundler';export const app = createApp({});import testcomponent from "./components/testComponent.vue";app.component('testcomponent',testcomponent);import othercomponent from "~/components/otherComponent.vue";app.component('othercomponent',othercomponent);app.mount('#vueApp');

But when I try register component inside other component its not work ...

app.js

import { createApp } from 'vue/dist/vue.esm-bundler';export const app = createApp({});import testcomponent from "./components/testComponent.vue";app.component('testcomponent',testcomponent);app.mount('#vueApp');

./components/testComponent.vue

<script setup>import {getCurrentInstance} from "vue";const instance = getCurrentInstance();import othercomponent from "~/components/otherComponent.vue";instance.appContext.app.component("othercomponent",othercomponent);</script><template>  <div>    <slot />  </div></template>

Im used inline-template in vue2 ... but how to make in vue3 I dont understand.

Im understand, slot is compiled. Maybe is it possible recompile after component registration or has other ways?

Help me please!

You must be logged in to vote

Replies: 0 comments

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Labels
None yet
1 participant
@mrFANRA

[8]ページ先頭

©2009-2025 Movatter.jp