怎么在markdown的表格嵌套一层div?

场景:使用vuepress在md写了一个表格,格式如下,想在渲染后的表格外套一层div,请问怎么处理?

| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---|---|---|---|---|
| type | 按钮组类型 | string | plain/bar | bar |
| size | 按钮组的大小 | string | normal/large | normal |

渲染结果为

clipboard.png
希望结果渲染结果为

clipboard.png

阅读 5.1k
2 个回答

.vuepress/components 文件夹下编写一个公共组件,名字叫 div-box.vue。内容如下

<template>
  <div class="table-box">
    <Content :slot-key="_id"></Content>
  </div>
</template>

<script>
  export default {
    name: "divBox",
    props: {
      _id: {
        type: String,
        required: true
      }
    }
  }
</script>

<style scoped>
.table-box {
  width: 100%;
  overflow-x: auto;
}
</style>

然后在md文件中添加如下内容即可

<div-box _id="tableAttributes"></div-box>

::: slot tableAttributes
| name | age |
| Link | 18 |
:::

在需要添加 div 标签的地方使用 ::: slot xxx 就可以了,_id 是为了区别哪一个 slot

打一波广告


v-easy-components是一款基于vue2.0的组件/指令库

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题