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: {}
})
Run Code Online (Sandbox Code Playgroud)
layout.blade.php
<body>
<div class="container">
<aside>...</aside>
<main id="mainview">
@section('content')
@show
</mainview>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
index.blade.php
@extends('layout')
@section('content')
<table>
<thead>
<tr>
<th>IDX</th>
<th>ID</th>
</tr>
</thead>
<tbody>
<users></users>
</tbody>
</table>
@endsection
Run Code Online (Sandbox Code Playgroud)
来自chrome控制台的ERROR LOG
[Vue警告]:无法在有状态组件根元素上使用v-for,因为它呈现多个元素:
<tr v-for="list …Run Code Online (Sandbox Code Playgroud) 我正在使用 node.js、express、pug、vue.js 创建网站。我有一个关于 Vue.js 的问题
应用程序.js
window.Vue = require('vue');
Vue.component('work-list', require('../views/components/WorkList.vue'));
const app = new Vue({
el: '#app',
data: {
message: 'Welcome'
}
});
Run Code Online (Sandbox Code Playgroud)
工作列表.vue
<script>
export default {
name: 'WorkList',
data: function () {
return {
message: 'WorkList Page'
}
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
索引.pug
(HTML Code..)
body
#app.container
h1 {{ message}}
.row
block content
a(href="/worklist") Go to worklist
script(src="bundle.js")
Run Code Online (Sandbox Code Playgroud)
工作清单.pug
extends index.pug
block content
work-list {{ message }}
Run Code Online (Sandbox Code Playgroud)
当我尝试访问工作列表页面时,浏览器返回以下错误消息。
如何在 Root 元素中制作 WorkList?