通知JS无法正常工作

时间:2017-10-17 18:43:23

标签: javascript jquery notifyjs

我正在研究Notify JS Notification选项。我试过但它不起作用。如果我删除Style和类名,它的工作正常。

   <style>

    .notifyjs-happyblue-base {
      white-space: nowrap;
      background-color: lightblue;
      padding: 5px;
    }
    .notifyjs-happyblue-superblue {
      color: white;
      background-color: blue;
    }
    </style>
<script src="http://code.jquery.com/jquery-3.0.0.min.js"></script>
<script src="notify.js"></script>
<script src="notify.min.js"></script>  

<script>

        $(function(){
          $.notify("Your Break is Approved", {
            style: 'happyblue',
            className: 'superblue'
            title: "E-Contact Application"
          });
     });
</script>

2 个答案:

答案 0 :(得分:3)

第一步,只包括一次脚本......你包括未包含的版本和缩小版本......

<script src="http://code.jquery.com/jquery-3.0.0.min.js"></script>
<!--<script src="notify.js"></script> DITCH THIS LINE -->
<script src="notify.min.js"></script>

第二步,确保你的语法正确......

$(function(){
    $.notify("Your Break is Approved", {
        style: 'happyblue',
        className: 'superblue', // <-- just a comma, but really important
        title: "E-Contact Application"
    });
});

全部放在一起......

&#13;
&#13;
<script src="https://code.jquery.com/jquery-3.0.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/notify/0.4.2/notify.min.js"></script>
<script>
    $.notify.addStyle('happyblue', {
     html: "<div>☺<span data-notify-text/>☺</div>",
     classes: {
        base: {
          "white-space": "nowrap",
          "background-color": "lightblue",
          "padding": "5px"
        },
        superblue: {
          "color": "white",
          "background-color": "blue"
        }
      }
    });


    $.notify("Your Break is Approved", {
        style: 'happyblue',
        className: 'superblue', // <-- just a comma, but really important
        title: "E-Contact Application"
    });
</script>
&#13;
&#13;
&#13;

答案 1 :(得分:1)

使用$.notify.addStyle(... befor $.notify("Message",...

&#13;
&#13;
$.notify.addStyle('happyblue', {
  html: "<span><span data-notify-text/></span>",
     classes: {
        base: {
          "white-space": "nowrap",
          "background-color": "lightblue",
          "padding": "5px"
        },
        superblue: {
          "color": "white",
          "background-color": "blue"
        }
      }
});

$.notify("Message", {
  style: 'happyblue',
  className: 'superblue'
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://rawgit.com/notifyjs/notifyjs/master/dist/notify.js"></script>
&#13;
&#13;
&#13;