Vue.js 如何在vue中使用儿童?

Vue.js 如何在vue中使用儿童?,vue.js,wrapper,Vue.js,Wrapper,我在不同的项目中使用React.js和Vue.js作为前端 在React中,我可以像这样用MyComponent包装模板 <MyComponent> <div>Here</div> </MyComponent> 在这里 在MyComponent文件中 const MyComponent = ({children}) { return ( <div className="my-comp

我在不同的项目中使用
React.js
Vue.js
作为前端

在React中,我可以像这样用
MyComponent
包装模板

    <MyComponent>
      <div>Here</div>
    </MyComponent>

在这里
在MyComponent文件中

const MyComponent = ({children}) {
    return (
         <div className="my-component">{children}</div>
    )
}
const MyComponent=({children}){
返回(
{儿童}
)
}
如何在
Vue.js
中使用此简单技术?

您将要使用的

下面是一个取自vuejs文档的示例

组件模板:

<a :href="url">
  <slot></slot>
</a>

守则:

<navigation-link url="/profile">
  Your Profile
</navigation-link>

你的个人资料
将被组件标签中的内容替换。它将被呈现为:

<a url="/profile">
  Your Profile
</a>

你的个人资料

您需要使用插槽。从这里阅读更多信息: