小编ofl*_*eaf的帖子

无法在有状态组件根元素上使用v-for,因为它呈现多个元素?

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)

components laravel blade vue.js

19
推荐指数
2
解决办法
2万
查看次数

无法挂载组件:未定义模板或渲染函数?

我正在使用 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?

javascript node.js express webpack vue.js

1
推荐指数
1
解决办法
4011
查看次数

标签 统计

vue.js ×2

blade ×1

components ×1

express ×1

javascript ×1

laravel ×1

node.js ×1

webpack ×1