【问题标题】:Table not Rendering properly with vuejs表格无法使用 vuejs 正确呈现
【发布时间】:2015-12-07 17:51:35
【问题描述】:

我有一个生成表格行的 vuejs 组件。该组件的代码如下。

组件加载表格上方的值,没有is='constitutionrow'这一行,而是带有is关键字,出现如下错误:

Uncaught RangeError 错误:超出最大调用堆栈大小

任何关于如何修复它的建议都会有所帮助。

    Vue.component('constitutionrow', {props: ['id','fid','jlpcandidate','constitution','pnpcandidate','votesjlp','votespnp'],
template:
" <tr 'constitutionrow'>" +
"<td> {{ id }}</td>" +
"<td>{{ fid }}</td>" +
"<td>{{ constitution }}</td> " +
"<td>{{ jlpcandidate }}</td>"  +
"<td>{{ pnpcandidate }}</td>" +
"<td>{{ votesjlp }}</td>"+
"<td>{{ votespnp }}</td>" +
" <td class='center'>" +
"<div>" +
"<a id='' class='glyphicon glyphicon-edit editbtn'  v-on:click='editRecord()'></a>" +
"</div>" +
"</td>" +
" </tr>",

data: function ()
 {

    return {

        hidden: true,
        show: false,
        selectedAnswerer:'',
    }
},
methods: {
    editRecord:function()
    {

        $('.editbtn').colorbox({
            html:"" +
            "<div id='editformConstituency'  class='form-group'>" +
            " <label >Fid</label> <input type='text'  v-model='fid' value='self.' class='form-control'> " +
            " <label >Constitution</label> <input type='text'  v-model='constitution' class='form-control'>"+
            " <label >JLP Candidate</label> <input type='text'  v-model='jlpCandidate' class='form-control'>"+
            " <label >PNP Candidate</label><input type='text'  v-model='phpCandidate' class='form-control'>" +
            " <label >Votes JLP </label> <input type='text'  v-model='votesJLP' class='form-control'>"+
            " <label >Votes PNP </label> <input type='text'  v-model='votesPnp' class='form-control'>"+
            "<button v-on:click='submitEdit()'>Submit</button>"+
            "  <script src='http://localhost/ElectionMapApplication/public/js/vuecontrollers/editFormConstituency.js'></script>" +
            "</div>",
            width: "75%",
            height: "75%",
            onComplete: function(){
                var bg = $.colorbox.element().data('bg');
                $('#cboxLoadedContent').css('backgroundColor', bg);
            }
        });
        },
}});

值出现在表格上方 Values Appear Above Table

【问题讨论】:

    标签: javascript vue.js


    【解决方案1】:

    该错误通常意味着您有一个正在调用自身的函数。那里的 HTML 是您的宪法行组件模板,但在其中您有一个 &lt;tr is='constitutionrow'&gt;,它正在创建另一个宪法行组件。这将无休止地继续下去。

    【讨论】:

    • 好的,但即使没有 is 关键字,值也会出现在表格上方,如您在链接中的图像中所见。关于如何修复它的任何建议
    • &lt;table&gt; 元素内的任何元素都必须是 &lt;tr&gt; 元素。例如,如果您尝试将&lt;div&gt; 放在表格中,它将出现在表格之外,就像您在这里一样。所以我猜你的代码说的是 `
      和 HTML 正在把它踢到桌子外面。
    • 如果您为constitutionrow 制作的模板只包含&lt;td&gt; 元素而不包含&lt;tr&gt; 包装器会怎样。然后在你的&lt;table&gt; 中你可以放置类似&lt;tr is='constitutionrow' v-for="...."&gt;
    猜你喜欢
    • 1970-01-01
    • 2012-08-23
    • 2011-08-13
    • 2018-02-14
    • 2016-02-14
    • 1970-01-01
    • 2014-03-19
    • 2015-03-18
    相关资源
    最近更新 更多