无法将 Vegas jQuery 插件添加到 运行

Unable to get Vegas jQuery plugin to run

我期待使用 Vegas jQuery 插件向 DOM 元素添加幻灯片。我写了一些简单的代码来测试它,但它似乎并不 运行。谁能告诉我我做错了什么?我尝试了几种变体,甚至查看了关于同一问题的一个现有答案 here,但似乎也没有用。

    $(function() {
        $.vegas('body', {
          backgrounds:[
          { src:'https://upload.wikimedia.org/wikipedia/commons/b/b4/JPEG_example_JPG_RIP_100.jpg'},
          { src:'https://upload.wikimedia.org/wikipedia/commons/b/b4/JPEG_example_JPG_RIP_100.jpg'}
          ]
        })
      });
body {
    width: 100%;
    height: 100%;
}

html {
    width: 100%;
    height: 100%;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0 0 35px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1px;
}
<head>
<link href="https://cdnjs.cloudflare.com/ajax/libs/vegas/2.2.0/vegas.min.css" rel="stylesheet"/>
</head>

<body>
<h1> Hello world </h1>
  
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/vegas/2.2.0/vegas.min.js"></script>
</body>

您应该在 jQuery 个选定项目上调用 "vegas",因此您的代码应如下所示:

$(function() {
  console.log($.fn.vegas)
  $('body').vegas({
    slides:[
      {src:'https://upload.wikimedia.org/wikipedia/commons/b/b4/JPEG_example_JPG_RIP_100.jpg'},
      {src:'https://upload.wikimedia.org/wikipedia/commons/b/b4/JPEG_example_JPG_RIP_100.jpg'}
    ]
  })
});

正如网站解释的那样:http://vegas.jaysalvat.com/documentation/setup/