<template>
  <div>
    <my-table></my-table>
    <my-table></my-table>
  </div>
</template>
<script>
import MyTable from './MyTable.vue'

export default {
  components: {
    MyTable
  }
}
</script> 
<p>// MyTable.vue
<template></p>
  <table>
    <thead>
      <tr>
        <th>姓名</th>
        <th>年龄</th>
        <th>性别</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>张三</td>
        <td>18</td>
        <td>男</td>
      </tr>
      <tr>
        <td>李四</td>
        <td>20</td>
        <td>女</td>
      </tr>
      <tr>
        <td>王五</td>
        <td>22</td>
        <td>男</td>
      </tr>
    </tbody>
  </table>
</template>
<script>
export default {
  name: 'MyTable'
}
</script
创建一个组件名称自取内容为一个表格内容随意。然后将这个组件在当前vue 实例div上以标签形式调用两次。

原文地址: https://www.cveoy.top/t/topic/c1cz 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录