【问题标题】:Is there a way to render markdown from declaration in Vue component有没有办法从 Vue 组件中的声明中渲染 markdown
【发布时间】:2019-05-23 06:21:55
【问题描述】:

本质上,我希望能够在实际组件本身中呈现组件声明中的内容。

另一个组件:

<Page>
    <h1>A title</h1>
    <p>An amazing paragraph</p>
</Page>

页面组件:

<template>
    <Header/>
    <!-- Here is where I want to render the title & paragraph-->
    <Footer/>
</template>

Vue 通过在应用程序的入口点公开&lt;router-view/&gt;,对路由器的视图执行类似的功能。除了整个组件之外,这基本上就是我想做的事情。

这可能吗?

【问题讨论】:

    标签: javascript vue.js frontend


    【解决方案1】:

    您只需在此处添加&lt;slot/&gt;

    <template>
        <Header/>
        <slot></slot>
        <Footer/>
    </template>
    

    查看:https://vuejs.org/v2/guide/components-slots.html

    【讨论】:

      猜你喜欢
      • 2020-08-12
      • 2022-01-11
      • 1970-01-01
      • 2023-03-29
      • 2020-11-20
      • 1970-01-01
      • 2018-07-03
      • 2018-12-17
      • 2021-11-10
      相关资源
      最近更新 更多