我正在使用 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 方法中起作用
这时候我会看很多的YouTube在谷歌的教程和文章后安装Nuxt JS,所以我对我的液滴基于Ubuntu 18.04已经安装节点JS之后,我第一次运行时npm init -y 和npm install nuxt --save 和npx 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)