link959 link960 link961 link962 link963 link964 link965 link966 link967 link968 link969 link970 link971 link972 link973 link974 link975 link976 link977 link978 link979 link980 link981 link982 link983 link984 link985 link986 link987 link988 link989 link990 link991 link992 link993 link994 link995 link996 link997 link998 link999 link1000 link1001 link1002 link1003 link1004 link1005 link1006 link1007 link1008 link1009 link1010 link1011 link1012 link1013 link1014 link1015 link1016 link1017 link1018 link1019 link1020 link1021 link1022 link1023 link1024 link1025 link1026 link1027 link1028 link1029 link1030 link1031 link1032 link1033 link1034 link1035 link1036 link1037 link1038 link1039 link1040 link1041 link1042 link1043 link1044 link1045 link1046 link1047 link1048 link1049 link1050 link1051 link1052 link1053 link1054 link1055 link1056 link1057 link1058 link1059 link1060 link1061 link1062 link1063 link1064 link1065 link1066 link1067 link1068 link1069 link1070 link1071 link1072 link1073 link1074 link1075 link1076 link1077 link1078 link1079 link1080 link1081 link1082 link1083 link1084 link1085 link1086 link1087 link1088 link1089 link1090 link1091 link1092 link1093 link1094 link1095

[Vue.js] Component inside the default slot

when fairly new to vue.js and currently am working on the first project with it.

there is encountered this problem which I cannot seem to find a solution for, there is “AuthPage.vue” component which has a slot for the message and default slot for content, once I put custom componen in my login.blade.php it should be prefilled in that slot but it says that custom element does not exist. If I replace slot inside .vue.js file with custom element it seems to be working perfectly. when not sure what when doing wrong.

AuthPage.vue

<template>
<div>
<div class=”page-brand-info”></div>

<div class=”page-login-main”>
<img class=”brand-img” src=”/assets/global/images/logo.jpg”>
<h3 class=”font-size-24 text-center”><slot name=”title”></slot></h3>
<slot name=”message”></slot>

<slot></slot>

<footer class=”page-copyright”>
<p> { moment().year() }. All RIGHT RESERVED.</p>
</footer>
</div>
</div>
</template>
<script>
import LoginForm from ‘./LoginForm.vue’;
import ResetPasswordForm from ‘./ResetPasswordForm.vue’;

export default {
components: { LoginForm, ResetPasswordForm }
}
</script>

login.blade.php

@extends(‘backoffice.layout.auth’)

@section(‘content’)
<auth-page>
<template v-slot:title>Sign In</template>

<login-form></login-form>
</auth-page>
@endsection

Thank you for the help!
Eddie

Solution :

You’ll need to register the LoginForm component globally in order for it to be passed into the AuthPage component as a slot (when passed in directly from a view). This is because, outside the scope of the component, vue.js doesn’t know what <login-form> is.

Since you’re using laravel, in the resources/js/app.js file add the following:

import LoginForm from ‘./path/to/LoginForm.vue’;

Vue.component(‘login-form’, LoginForm);