[英]How to fix Vue warn]: Unknown custom element: <password-input>?
我正在尝试修复组件中的以下错误,但它仍然失败。 错误如下:
[Vue 警告]:未知的自定义元素:-您是否正确注册了组件? 对于递归组件,请确保提供“名称”选项。
在我的密码组件中,按照脚本,我有以下内容:
<template>
<div class="form-group form-material floating" data-plugin="formMaterial">
<input id="password" type="password" class="form-control" name='password'>
<label class="floating-label">Create password</label>
<span class="password-info"><i class="fa fa-info-circle"></i></span>
<div class="password-rules">minimum 6 characters</div>
<span v-if="this.error != null" :class="['invalid-feedback', {'inline': this.error != null}]">
<strong>{{ error }}</strong>
</span>
</div>
</template>
<script>
import Password from 'password-strength-meter'
export default{
props: ['error'],
mounted: function(){
const $password = $('#password', this.$el);
$password.password({
showText: false,
animate: true,
});
}
}
</script>
<style lang="scss">
@import '~password-strength-meter/dist/password.min.css';
</style>
问题是页面打开时vue组件没有加载,刷新时错误消失。
在 Laravel Blade 中,我按以下方式使用它:
<password-input @if($errors->has('password')) :error="'{{$errors->first('password')}}'" @endif></password-input>
在 app.js 中
我有以下脚本
new Vue({
el: '#app'
});
有人可以指导我如何修复它吗? 如果有人可以指导我解决这个问题,我将不胜感激。 我见过这个问题,但它没有解决我的问题。
组件是否已注册,通常是在您在 app.js 文件中创建 Vue 实例时。
const app = new Vue({
el: '#app',
components: { ExampleComponent } // Note!!!
});
您可以在此处找到更多信息: https : //laracasts.com/discuss/channels/vue/little-help-with-laravel-and-vue-components-registration
嘿,你有没有深入了解这件事? 我整天都在为同样的事情苦苦挣扎。 间歇性的部分一直在扼杀我的生产力,哈哈。 反正。 像您一样,我在<template>
部分使用了="this.myVar"
而不是="myVar"
并且当我更改后,此问题就没有发生过。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.