0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【10行】Vue コンポーネントをコンポーネントに動的に追加

Last updated at Posted at 2021-02-12
動的に増やしたい子コンポーネント(MyComponent.vue)
<template>
 <div>{{ msg }}</div>
</template>

<script>
var Comp = Vue.extend({
  props: {
    msg: ""
  }
})
</script>
追加先の親コンポーネント
<template>
 <div>Parent Page</div>
 <div id="parentcomponentdiv"></div>
</template>

<script>
let compo = new MyComponent();
compo.$props.msg = "hoge";
compo.$mount();
document.getElementById("parentcomponentdiv").appendChild(compo.$el);
</script>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?