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.
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:
The component:
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.