Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何定义背景滑块的背景以及如何修复它?_Javascript_Reactjs_Gatsby_Gatsby Image - Fatal编程技术网

Javascript 如何定义背景滑块的背景以及如何修复它?

Javascript 如何定义背景滑块的背景以及如何修复它?,javascript,reactjs,gatsby,gatsby-image,Javascript,Reactjs,Gatsby,Gatsby Image,我正在尝试为一家餐厅制作背景滑块。出于这个原因,我使用了盖茨比图像背景滑块。当我执行“gatsby develop”时,它在执行时没有显示错误,但当我尝试在localhost中浏览时,它显示错误“×” TypeError:无法读取未定义“”的属性“backgrounds” 源代码可以在这里找到 我想使用旋转木马,但我认为使用这个插件会更好。这是我在盖茨比的第一次尝试。我已经安装了插件,并尝试在graphql中进行查询。根据盖茨比图像背景滑块文档,没有提到将目录提供给背景。我试图在relative

我正在尝试为一家餐厅制作背景滑块。出于这个原因,我使用了盖茨比图像背景滑块。当我执行“gatsby develop”时,它在执行时没有显示错误,但当我尝试在localhost中浏览时,它显示错误“×” TypeError:无法读取未定义“”的属性“backgrounds”

源代码可以在这里找到

我想使用旋转木马,但我认为使用这个插件会更好。这是我在盖茨比的第一次尝试。我已经安装了插件,并尝试在graphql中进行查询。根据盖茨比图像背景滑块文档,没有提到将目录提供给背景。我试图在relativepath中输入一些,但它显示错误,文档中并没有提到


你知道我该如何消除这个错误吗?我可以用一个背景滑块或类似转盘的东西来优化吗?

你需要将BackgroundSection组件更改为:

export default function BackgroundSection({
  img,
  styleClass,
  children,
  title,
  query // you forgot this
}) {
  return (
    <BackgroundSlider className={styleClass} fluid={img} query={query}>
      <div class="container">
        <div class="row align-items-center justify-content-center">
          <div class="col-xl-9 col-md-9 col-md-12">
            <div class="slider_text text-center bold">
              <div>
                <h1>{title}</h1>
              </div>
              <div>
                <h1>{title}</h1>
              </div>
            </div>
          </div>
        </div>
      </div>

      {children}
    </BackgroundSlider>
  )
}
export default function BackgroundSection({
img,
样式类,
儿童
标题
你忘了这个
}) {
返回(
{title}
{title}
{儿童}
)
}

忘记了包含查询,并将该查询传递到BackgroundSLider组件中

您需要将BackgroundSection组件更改为:

export default function BackgroundSection({
  img,
  styleClass,
  children,
  title,
  query // you forgot this
}) {
  return (
    <BackgroundSlider className={styleClass} fluid={img} query={query}>
      <div class="container">
        <div class="row align-items-center justify-content-center">
          <div class="col-xl-9 col-md-9 col-md-12">
            <div class="slider_text text-center bold">
              <div>
                <h1>{title}</h1>
              </div>
              <div>
                <h1>{title}</h1>
              </div>
            </div>
          </div>
        </div>
      </div>

      {children}
    </BackgroundSlider>
  )
}
export default function BackgroundSection({
img,
样式类,
儿童
标题
你忘了这个
}) {
返回(
{title}
{title}
{儿童}
)
}

如果指定要包含的图像(图像={[]}),请确保图像名称存在于图像文件夹中

如果指定要包含的图像(图像={[]}),请确保图像名称存在于图像文件夹中确保图像名称存在于图像文件夹中

未工作。现在它显示的是:TypeError:cannotread未定义回调的属性'style'C:/Myfiles/for_react/Gatsbyjs/src/index.js:104 101 | const callback=function(){102 | const index=indexRef.current;103 |>104 | bgWrappers[index].style.opacity=0;105 | bgWrappers[(index+1)%length].style.opacity=1;106 | 107 |子包装器[index].style.opacity=0;我通过导入{Carousel}完成了它来自gatsby bootstrap,但我想尝试一下backgroundslider。但是luckI仍然没有时间更深入地研究代码…也许backgroundsliderthanx中有一些bug,因为您迄今为止所做的努力…在完成此任务后将对其进行研究不起作用。现在它显示:TypeError:无法读取未定义callba的属性“style”ck C:/Myfiles/for|react/Gatsbyjs/src/index.js:104 101 | const callback=function(){102 | const index=indexRef.current;103 |>104 | bgWrappers[index]。style.opacity=0;105 | bgWrappers[(index+1)%length]。style.opacity=1;106 | 107 | subWrappers[index].style.opacity=0;我通过从gatsby bootstrap导入{Carousel}完成了这项工作,但我想尝试一下backgroundslider。但是luckI仍然没有时间对代码进行更深入的研究……也许backgroundsliderthanx中存在一些bug,这是您迄今为止所做的工作……在完成这项工作后,我们将对其进行研究