laravel - Vue.js | 组件不工作。| 未知的自定义元素:
问题描述
我有这个错误:
[Vue 警告]:未知的自定义元素:
<image-upload>
- 您是否正确注册了组件?对于递归组件,请确保提供“名称”选项。
在 myApp.js 我添加:
Vue.component('image-upload',require('./components/ImageUpload.vue').default);
在ImageUpload.Vue我有这个代码:
<script>
import Croppie from 'croppie'
export default {
props: ['imgUrl'],
mounted() {
this.image = this.imgUrl
this.setupCroppie()
},
data() {
return {
croppie: null,
image: null
}
},
methods: {
setUpCroppie() {
let el = document.getElementById('croppie')
this.croppie = new Croppie(el, {
viewport: {width: 200, height: 200, type: 'circle'},
boundary: {width: 220, height: 220},
showZoomer: true,
enableOrientation: true
})
this.croppie.bind({
url: this.image
})
},
}
}
</script>
<template>
<div class="image-upload-wrapper image-upload">
<p>this is my component</p>
<div id="croppie"></div>
</div>
</template>
在刀片中:
<image-upload img-url="{{url('img/user.png')}}"></image-upload>
我在这里关注文档以使用 CroppieJs https://foliotek.github.io/Croppie/
谢谢..
解决方案
您是否尝试将 : 添加到您的 vue 组件中。
<image-upload :img-url="{{url('img/user.png')}}"></image-upload>
Vue 组件是否出现在 Vue.js 检查器中?
https://chrome.google.com/webstore/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd
推荐阅读
- html - 使用内联 SVG 和文本进行锚点悬停
- reactjs - 在 React 中使用 onClick 更改元素内容
- crystal-reports - 多行字符串,设置在一行
- angular - 将“dotnet new angular”创建的应用部署到 Azure 失败
- postgresql - 从 PostgreSQL 中的 JSONB 列中提取数组数据并使用 pgx 库将其编组为字符串切片
- keras - 使用 LSTM 神经网络预测天然气价格
- javascript - Payload Too Large - 当尝试上传大于 10MB 的文件时,在 dropzone.js 的控制台中显示
- reactjs - 创建帖子传奇后重定向到创建的帖子
- docker - 使用 Nginx 反向代理的 Rancher
- c# - 实体框架:多个数据库版本