【发布时间】:2017-10-26 21:21:40
【问题描述】:
app.js
var Users = {
template: `
<tr v-for="list in UsersData">
<th>{{ list.idx }}</th>
<td>{{ list.id }}</td>
</tr>
`,
data: function () {
return {
UsersData //get data from query
}
}
}
var mainview = new Vue({
el: "#mainview",
components: {
'users': Users
},
method: {}
})
layout.blade.php
<body>
<div class="container">
<aside>...</aside>
<main id="mainview">
@section('content')
@show
</mainview>
</div>
</body>
index.blade.php
@extends('layout')
@section('content')
<table>
<thead>
<tr>
<th>IDX</th>
<th>ID</th>
</tr>
</thead>
<tbody>
<users></users>
</tbody>
</table>
@endsection
来自 chrome 控制台的错误日志
[Vue 警告]:不能在有状态组件根元素上使用 v-for,因为它会渲染多个元素:
<tr v-for="list in UsersData">
<th>{{ list.idx }}</th>
<td>{{ list.id }}</td>
</tr>
vue.js:525 [Vue 警告]:从渲染函数返回多个根节点。渲染函数应返回单个根节点。 (在组件中找到)
我应该如何修复代码?
【问题讨论】:
标签: laravel vue.js components blade