在Laravel中使用Vue插件时出错:未知的自定义元素:< simplert> [英] Error when using Vue plugin in Laravel: Unknown custom element: <simplert>

查看:233
本文介绍了在Laravel中使用Vue插件时出错:未知的自定义元素:< simplert>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Laravel 5.7应用程序中使用 Simplert Vue插件,但是我收到以下错误:

I am trying to use the Simplert Vue plugin within my Laravel 5.7 app but I'm getting the following error:

[Vue警告]:未知的自定义元素:-您是否注册了 组件正确吗?对于递归组件,请确保提供 名称"选项.

[Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.

我的代码基于以下问题的答案 Vue.js 2-甜蜜警报程序包simplert无法正常工作

I have based my code on answer from this question 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模板:

home.blade.php template:

@section('content')
  // ..
  <simplert></simplert>
  // ..

package.json:

package.json:

"dependencies": {
    "vue2-simplert-plugin": "^0.5.3"
}

在VSCode中,我的app.js文件中的以下行import Simplert from 'vue2-simplert-plugin'上有一个提示:

In VSCode, there is a hint on the following line import Simplert from 'vue2-simplert-plugin' in my app.js file:

找不到模块'vue2-simplert-plugin'的声明文件. 'x/node_modules/vue2-simplert-plugin/dist/vue2-simplert-plugin.js' 隐式地具有"any"类型.

Could not find a declaration file for module 'vue2-simplert-plugin'. 'x/node_modules/vue2-simplert-plugin/dist/vue2-simplert-plugin.js' implicitly has an 'any' type.

这可能是问题吗?

推荐答案

我不知道为什么,但是我遇到了同样的问题,一旦插件在App.vue中注册,某些组件就可以正常工作:

I don't know why but i faced the same issu and once the plugin is registered in App.vue, some components works fine with:

<Simplert></Simplert> 

,还有一些

<simplert></simplert>

唯一的区别是大写/小写,但是某些组件接受大写,而其他则不接受,我必须使用小写.

The only diff is the Uppercase / Lowercase but some components accepts the Uppercase when other not and i must use Lowercase.

这篇关于在Laravel中使用Vue插件时出错:未知的自定义元素:&lt; simplert&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆