首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用VueJS2绘制表

用VueJS2绘制表
EN

Stack Overflow用户
提问于 2017-10-09 14:35:30
回答 1查看 41关注 0票数 0

为了进行服务器呈现,我将JQuery管理的表迁移到VueJS ( 2.4.4 ),我使用Laravel,因此:

代码语言:javascript
复制
<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>

在我的组件模板中,<association-item>是:

代码语言:javascript
复制
<template>
    <tr>
        <td>
            {{ association.name }}
        </td>
        <td align="center">association</td>
    </tr>
</template>

然后,我将组件链接到标记上:

代码语言:javascript
复制
Vue.component('association-item', require('../components/AssociationItem.vue'));

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

所以,当我看到源代码时,我的<association-item>就在<tbody></tbody>中了。

但是在屏幕上,数据在标题之前,当我用Chrome进行调试时,我可以看到所有的<tr>item</tr>都在<div class='container-fluid'<table>之间

为什么会发生这种事?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-10-09 14:56:08

tbody的唯一标记是tr

您应该能够使用

代码语言:javascript
复制
<tr is="association-item" ...>

使HTML合法。(可能需要是is="associationItem"。)

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46648951

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档