drwkqwa82140 2017-10-09 14:35 采纳率: 0%
浏览 23
已采纳

使用VueJS2渲染表

I'm migrating a table managed by JQuery to VueJS ( 2.4.4 ) For server rendering, I use Laravel, so :

<div class="container-fluid">
<table class="table table-togglable table-hover">
    <thead>
        <tr>
            <th data-toggle="true">Name</th>
            <th class="text-center" data-hide="phone">Federation</th>
        </tr>
    </thead>
    <tbody>
        @foreach($associations as $association) // This is Laravel blade
            <association-item
                    :association="{{ json_encode($association) }}"
                    :url_edit="{{ json_encode(route('associations.edit', $association)) }}"
                    :url_delete="{{ json_encode(route('api.associations.delete', $association)) }}"
            >
            </association-item>
        @endforeach
    </tbody>
</table>
</div>

and inside my component template, <association-item> is:

<template>
    <tr>
        <td>
            {{ association.name }}
        </td>
        <td align="center">association</td>
    </tr>
</template>

Then I link my component to the tag with:

Vue.component('association-item', require('../components/AssociationItem.vue'));

const app = new Vue({
    el: '#app'
});

So, it works, when I see source, I have my <association-item> inside <tbody></tbody>

But in the screen, data is before header, and when I debug with Chrome, I can see that all <tr>item</tr> are just between <div class='container-fluid' and <table>

Why is it happening???

  • 写回答

1条回答 默认 最新

  • donglian5309 2017-10-09 14:56
    关注

    The only tags permitted as direct children of tbody are tr.

    You should be able to specify the component using

    <tr is="association-item" ...>
    

    to make the HTML legal. (It may need to be is="associationItem".)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复