首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我的Vue组件没有出现在Laravel

我的Vue组件没有出现在Laravel
EN

Stack Overflow用户
提问于 2021-10-01 19:03:39
回答 1查看 178关注 0票数 1

我的vue组件没有出现,我看不出这里出了什么问题。我的控制台没有错误,我使用npm运行热。

My app.js

代码语言:javascript
复制
require('./bootstrap');

window.Vue = require('vue').default;

/**
 * The following block of code may be used to automatically register your
 * Vue components. It will recursively scan this directory for the Vue
 * components and automatically register them with their "basename".
 *
 * Eg. ./components/ExampleComponent.vue -> <example-component></example-component>
 */

// const files = require.context('./', true, /\.vue$/i)
// files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default))

Vue.component('follow-button', require('./components/FollowButton.vue').default);

/**
 * Next, we will create a fresh Vue application instance and attach it to
 * the page. Then, you may begin adding components to this application
 * or customize the JavaScript scaffolding to fit your unique needs.
 */

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

我的FollowButon.vue组件

代码语言:javascript
复制
<template>
    <div>
        <button class="btn btn-primary ml-4"  v-text="buttonText"></button>
    </div>
</template>

<script>
    export default {
        mounted() {
            console.log('Component mounted.')
        }

        
    }
</script>

Place vue应该在那里显示

代码语言:javascript
复制
extends('layouts.app')

@section('content')
<div class="container">
    <div class="row">
        <div class="col-3 p-5">
            <img src="{{ $user->profile->profileImage() }}"  class="rounded-circle w-100">
        </div>
        <div class="col-9 pt-5">

        <div class="d-flex justify-content-between align-items-baseline">
            <div class="d-flex align-items-center pb-3">
                <div class="h4">{{$user->name}}</div>
                 
                 <follow-button></follow-button>
                
            </div>

            @can('update',$user->profile)
            <a href="/p/create">Add New Post</a>
            @endcan

        </div>
         @can('update',$user->profile)
            <a href="/profile/{{ $user->id }}/edit">Edit profile</a>
        @endcan

        <div class="d-flex">
            <div class="pr-5"><strong>{{ $user->posts->count() }}</strong> posts</div>
            <div class="pr-5"><strong>23k</strong> followers</div>
            <div class="pr-5"><strong>212</strong> following</div>
        </div>
        <div class="pt-4"><strong>{{ $user->profile->title}}</strong></div>
        <div>{{ $user->profile->description}}</div>
        <div><a href="#">{{$user->profile->url}}</a></div>
        </div>
    </div>

    <div class="row pt-5">
        @foreach($user->posts as $post)
        <div class="col-4 pb-5">
            <a href ="/p/ {{ $post->id }}">
            <img src="/storage/{{ $post->image }}"; class="w-100">
            </a>
        </div>
        @endforeach
    </div>


</div>
@endsection

我在我的<head>区有这个

代码语言:javascript
复制
<script src="{{ asset('js/app.js') }}" defer></script>

如果我把这个改成

代码语言:javascript
复制
<link rel="stylesheet" href="{{ mix('css/app.css') }}" />
<script defer src="{{ mix('js/app.js') }}"></script>

它还是没用的

而且,here的任何回答都不适合我。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-10-01 19:11:58

必须将app Id添加到<follow-button></follow-button>的元素父级

像这样

代码语言:javascript
复制
<div id="app">
   <follow-button></follow-button>
</div>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69410880

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档