laravel 5.4 Vue 组件不工作

laravel 5.4 Vue Component not workng

我在

等组件中有一个 Chat-User.vue 文件
<template lang="html">
    <div class="chat-user">
        <a href="#" class="close" v-on:click="hideUsers">&times;</a>
        <h1>Users in Chat Room</h1>
        <hr />
        Number of users = {{ usersInRoom.length }}
        <div class="users" style="overflow: hidden;">
            <div class="col-sm-3 w3-margin-bottom" v-for="userInRoom in usersInRoom" style="overflow: hidden;">
                <div class="u-1">
                    <img :src="userInRoom.profile" width="50" height="50">
                </div>
                <div class="u-2">
                    {{ userInRoom.name }}
                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    props: ['usersInRoom']
}
</script>

我的 app.js 文件

Vue.component('chat-user', require('./components/Chat-User.vue'));

const app = new Vue({
    el: '#app',
    data: {
        usersInRoom: []
    },
});

indx.blade.php 文件

<div id="app">
    <chat-user v-bind:usersInRoom="usersInRoom"></chat-user>
</div>

usersInRoom变量中它会自动添加数据。

但是当我查看浏览器时,我在 <chat-user></chat-user> 的地方看不到任何东西,只有 <!---->.

我认为它出于某种原因被 vue 注释掉了。我尝试删除所有 {{ usersInRoom }} 然后我可以看到其他东西,例如 <h1>Users in Chat Room</h1><hr>.

如果我没记错组件文件无法识别任何像 usersInRoom 这样的变量,而我有这样的变量。

请有人告诉我如何解决这个问题。

Html 指令不区分大小写,在 documentation Vue 中提到您需要在绑定道具中使用 kebab-case。

尝试 <chat-user v-bind:users-in-room="usersInRoom"></chat-user> 它将绑定到 usersInRoom 属性。

道具不能用驼峰式的。你需要使用烤肉盒。

并从 vue 1 绑定,您可以删除 "v-bind" 字符串并直接从 :

开始
<chat-user :users-in-room="usersInRoom"></chat-user>