vuejs / Discussion

Vue.js discussion
167 stars 17 forks source link

Slots rendering as strings inside textareas #492

Open dbatten5 opened 8 years ago

dbatten5 commented 8 years ago

In this example, the 'body' slot is being rendered as a string. Is there any way to pass the actual data in the slot to the textarea in the component?

The view:

<div id='app'>
  <my-component>
    <div slot="body">
      Test
    </div>
  </my-component>
</div>

The component:

Vue.component('my-component', {
    template:
  '<textarea><slot name="body"></slot></textarea>'
});

new Vue({
    el:'#app',
});

The output is a textarea with prefilled in the textarea rather than 'Test' prefilled in the textarea.

I could instead assign body as prop and pass in the data to the textarea by attached a v-model="body" to the textarea, but in the situation where I want to pass in large amounts of text, passing it in as a single string via a prop seems a little clumsy.

milewski commented 8 years ago

+1