【发布时间】:2019-06-23 16:49:16
【问题描述】:
我正在尝试在我的 Laravel 5.7 应用程序中使用 Simplert Vue plugin,但出现以下错误:
[Vue 警告]:未知的自定义元素:- 你是否注册了 组件正确吗?对于递归组件,请确保提供 “名称”选项。
我的代码基于这个问题的答案Vue.js 2- sweet alert package simplert not working
app.js 文件:
require('./bootstrap');
window.Vue = require('vue');
import Simplert from 'vue2-simplert-plugin'
require('vue2-simplert-plugin/dist/vue2-simplert-plugin.css')
Vue.use(Simplert)
const app = new Vue({
el: '#app',
data: {
obj: {
title: 'Alert Title',
message: 'Alert Message',
type: 'info',
useConfirmBtn: true,
customConfirmBtnText: 'OK'
}
},
methods: {
openSimplert () {
this.$Simplert.open(this.obj)
},
closeSimplert () {
this.$Simplert.close()
}
}
})
home.blade.php 模板:
@section('content')
// ..
<simplert></simplert>
// ..
package.json:
"dependencies": {
"vue2-simplert-plugin": "^0.5.3"
}
在 VSCode 中,在我的 app.js 文件中的以下行 import Simplert from 'vue2-simplert-plugin' 上有一个提示:
找不到模块“vue2-simplert-plugin”的声明文件。 'x/node_modules/vue2-simplert-plugin/dist/vue2-simplert-plugin.js' 隐式具有“任何”类型。
这可能是问题吗?
【问题讨论】:
-
您解决了这个问题吗?我也有同样的问题