【问题标题】:Vue component not loading the dataVue组件未加载数据
【发布时间】:2017-06-19 01:05:38
【问题描述】:

我正在使用 Vue 组件测试 Laravel 5.4。但问题是 Vue 组件没有显示在视图页面中。

这是我的 Vue 文件:

ChatMessage.vue

<template>
    <div>
        <p>Message text is here</p>
        <small>Author Name</small>
    </div>
</template>

<script>

</script>
<style>
</style>

这是刀片 chat.blade.php

<html>
    <head>
        <title>Chat Rool</title>
        <link rel="stylesheet" href="css/app.css">
    </head>
    <body>
        <div id="app">
            <h1>Chat Room</h1>          
            <chat-message></chat-message>
        </div>
        <script src="js/app.js" charset="utf-8"></script>
    </body>
</html>

这是我的 app.js

require('./bootstrap');

Vue.component('chat-message', require('./components/ChatMessage.vue'));

const app = new Vue({
    el: '#app'
});

加载app.js没有错误,因为我已经检查过它在视图页面中。 谁能建议我这里有什么问题?

【问题讨论】:

    标签: laravel vue.js vue-component laravel-5.4


    【解决方案1】:

    您的 ChatMessage.vue 中似乎只需要导出一个空对象,因为没有任何其他属性,如下所示:

    <template>
        <div>
            <p>Message text is here</p>
            <small>Author Name</small>
        </div>
    </template>
    
    <script>
    export default {
    }
    </script>
    <style>
    </style>
    

    【讨论】:

    • @Hola您可以从问题中删除解决方案,我看到您在问题中添加了这个,如果其他人稍后查看这个问题会混淆。
    • 对,我想我已经检查过了!我已经编辑了..谢谢你的解决方案
    • @Saurabh 也许你可以帮助我。看看这个:stackoverflow.com/questions/49664451/…
    猜你喜欢
    • 2020-03-27
    • 2019-04-21
    • 1970-01-01
    • 2018-10-11
    • 1970-01-01
    • 2021-06-08
    • 2020-08-18
    • 2021-01-28
    • 1970-01-01
    相关资源
    最近更新 更多