简体   繁体   English

在Laravel 5.6中安装和使用Sweet Modal Vue npm软件包

[英]Installing and using Sweet Modal Vue npm package in Laravel 5.6

So I have been searching through Stack Overflow and reading to the responses to similar questions as this but they have not helped me at all in better understanding this: 因此,我一直在搜索“堆栈溢出”并阅读对类似问题的回答,但是它们根本没有帮助我更好地理解这一点:

I wanted to use this Sweet Modal Vue package ( https://sweet-modal-vue.adepto.as/ ) for my Laravel 5.6 project (I am using the Laravel Homestead setup btw). 我想为我的Laravel 5.6项目使用这个Sweet Modal Vue包( https://sweet-modal-vue.adepto.as/ )(我正在使用Laravel Homestead安装程序顺便说一句)。 Installed it via npm and it is contained within my node_modules folder. 通过npm安装它,它包含在我的node_modules文件夹中。

Now I am trying to use it within my project. 现在,我正在尝试在我的项目中使用它。 I have tried following the instructions on the documentation to no avail, after which I tried using 我尝试遵循文档中的说明无济于事,之后尝试使用

window.SweetModalVue = require('sweet-modal-vue');

in the app.js file first and then tried I tried using it in the bootstrap.js file. 首先在app.js文件中,然后尝试在bootstrap.js文件中尝试使用它。 And after I compile and try inserting 在我编译并尝试插入后

<sweet-modal>Well Hello There</sweet-modal>

in my blade template code, I keep getting an error message of 在刀片模板代码中,我不断收到错误消息

ReferenceError: SweetModal is not defined ReferenceError:未定义SweetModal

I don't see any tutorials at all (articles or video tutorials) on how this process works on Laravel 5.6. 我完全看不到任何有关Laravel 5.6的工作原理的教程(文章或视频教程)。 Could anyone let me know what I am doing wrong? 谁能让我知道我在做什么错?

You can install component globally 您可以全局安装组件

const SweetModal = require('sweet-modal-vue/plugin.js').default
Vue.use(SweetModal)

then in your code 然后在你的代码中

<sweet-modal>Well Hello There</sweet-modal>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM