使用具体化吐司时的错误消息

error message when using materializes toast

我正在尝试调用 Googles materializecss 中的 M.toast() 函数,但我收到一条错误消息:

Uncaught ReferenceError: M is not defined

index.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>My App</title>

    <link rel="stylesheet" type="text/css" href="styles/materialize.css">
    <link rel="stylesheet" type="text/css" href="styles/style.css">

    <script type="text/javascript" src="scripts/jquery-3.3.1.js"></script>
    <script type="text/javascript" src="scripts/materialize.js"></script>
  </head>
  <body>
    <form action="#">
      <button class="waves-effect waves-light btn" id="submit" type="submit" name="submit">
        Submit
      </button>
    </form>

    <script type="text/javascript" src="scripts/register.js"></script>

  </body>
</html>

register.js

(function() {
  'use strict';

  $('form').submit(
    function(e) {
      let $radio = $("input:radio[name='myradio']");

      if (!$radio.is(':checked')) {
        e.preventDefault();
        toast();

        return false;
      }
    });

  function toast() {
    M.toast({html: 'Bitte alle Felder auswählen!'});
  }
})();

我是不是忘了添加一些东西或者怎么了?

解决方案:将 MaterializeCSS 更新至版本 1.0.0