小编Ami*_*ddi的帖子

参考错误:“Swal 未定义”

我正在使用 codeigniter 和 VueJs 以及甜蜜警报 javascript 库进行小型项目。但是ReferenceError: "Swal is not defined"一旦我swall.fire({})在我的 VueJs 方法中调用,我的控制台就会出错。 这是我的代码:

deleteCustomers(customer_id){
        Swal.fire({
           title: 'Are you sure?',
           text: "You won't be able to revert this!",
           icon: 'warning',
           showCancelButton: true,
           confirmButtonColor: '#3085d6',
           cancelButtonColor: '#d33',
           confirmButtonText: 'Yes, delete it!'
           }).then((result) => {
              axios.post('/Thirdparty/deleteCustomers', {id : customer_id}).then(function(response){
                 console.log(response.data);
                 //alert(response.data.error);
                 Swal.fire(
                 'Deleted!',
                 'Your file has been deleted.',
                 'success'
                 );
              });
           });
     }
Run Code Online (Sandbox Code Playgroud)

当然,我已经使用以下方法导入了 swall: import Swal from 'sweetalert2';

注意:swall.fire 不仅在 Vuejs 方法中起作用

javascript vue.js sweetalert vuejs2

5
推荐指数
2
解决办法
3万
查看次数

为什么我得到“找不到模块”我已经尝试了很多解决方案

这时候我会看很多的YouTube在谷歌的教程和文章后安装Nuxt JS,所以我对我的液滴基于Ubuntu 18.04已经安装节点JS之后,我第一次运行时npm init -ynpm install nuxt --savenpx create-nuxt-app project和收到此错误信息:

module.js:549
    throw err;
    ^

Error: Cannot find module '/root/.npm/_npx/1934/lib/node_modules/create-nuxt-app/node_modules/ejs/postinstall.js'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:188:16)
    at bootstrap_node.js:609:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ejs@2.7.4 postinstall: `node ./postinstall.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the ejs@2.7.4 postinstall script.
npm ERR! This is probably not a problem with npm. There is …
Run Code Online (Sandbox Code Playgroud)

vue.js nuxt.js

2
推荐指数
1
解决办法
6186
查看次数

标签 统计

vue.js ×2

javascript ×1

nuxt.js ×1

sweetalert ×1

vuejs2 ×1