Vue.js 如何在html参数中添加插槽?
在我的Vue.js组件中,我需要在参数中使用slot,但我的尝试不起作用。有没有办法做到这一点Vue.js 如何在html参数中添加插槽?,vue.js,vue-component,Vue.js,Vue Component,在我的Vue.js组件中,我需要在参数中使用slot,但我的尝试不起作用。有没有办法做到这一点 new Vue({ el: '#app', components: { 'test': { template: ` <iframe width="300px" height="200px" src="https://www.youtube.com/embed/<slot></slot>"&g
new Vue({
el: '#app',
components: {
'test': {
template: `
<iframe width="300px" height="200px" src="https://www.youtube.com/embed/<slot></slot>"></iframe>
`
}
}
})
新Vue({
el:“#应用程序”,
组成部分:{
“测试”:{
模板:`
`
}
}
})
插槽用于插入需要道具的html
试试这个,会有用的
components: {
test:{
template:'<iframe width="300px" height="200px" :src="url"></iframe>',
props: ['url'],
}
}
组件:{
测试:{
模板:“”,
道具:['url'],
}
}
并从家长处传递您的url
<test url="https://www.youtube.com/embed/-rCZNFARSfQ" />
为什么不使用道具呢?这不是插槽的用途。