私のコードスニペットはこのように見えますが、私はpackage.jsonのsweetalertを持っています。reactJs、Redux、import sweetalertの使用中にウィンドウが定義されていません
import swal from 'sweetalert'; export function delete() {
return (dispatch, getState) => {
swal({
title: "Delete API?",
text: "You will not be able to recover this API!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: false
});}
ウィンドウが定義されていないエラーがパブリック/ server.js
if(window.console){
では、これはsweetalert
にrealtedされます。
私はしばらくの間、この作業を持っていましたが、私が行った時にきれいなNPMの実行がそれを構築するには、私はいくつかの提案をする場合、サーバー側でそれをレンダリングしないように見server.js
を置き換え、コードのこの新しいラインはserver.js
に追加されますreact/reduxを使用していますが、レンダリング中にsweetalertパッケージをロードしない方法を探しています。
ご協力いただきまして誠にありがとうございます。ありがとう
オリジナルのSweetalertプラグインはサポートされていません。[Sweetalert2](https://github.com/limonte/sweetalert2)をご覧ください。 –
@limonte私もsweetalert2を試しました。上記。私はあなたがsweetalert2で多く働いているのを見ました。私はあなたがそのパッケージを所有していると思います。私がsweetalert2を使用しているときに、public/server.js – NagaRajendra