1

Есть два компонента

    Vue.component('my-temp', {
      template: '<div><span></span></div>'
    });

    Vue.component('my-temp-1', {
      template: '<h1>test</h1>'
    });

    let vm = new Vue({
      el: "#app"
    });


  <div id="app">
    <!--<my-temp>
      <my-temp-1></my-temp-1>
     </my-temp>-->
  </div>

Мне нужно, чтобы компонент my-temp-1 оказался внутри тега span компонента my-temp. Как это можно реализовать?

2

1 ответ 1

5
Vue.component('my-temp', {
      template: '<div>
 <span>
  <slot></slot>
 </span></div>'
    });

Vue.component('my-temp-1', {
      template: '<h1>test</h1>'
    });

<div id="app">
    <my-temp>
      <my-temp-1/>
     </my-temp>
  </div>

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.