简体   繁体   English

React-Slick轮播-在父级组件的prop触发下,自动播放在子级组件中不起作用

[英]React-slick carousel - autoplay not working in child component while triggering it with prop from parent component

I m using React. 我正在使用React。 I am trying to implement a carousel and I tried to trigger auto play option(props for Slider literally) in react-slick , the autoplay in react-slick is not working. 我正在尝试实现轮播,并且试图在react-slick中触发自动播放选项(字面上为Slider的道具),在react-slick中的自动播放不起作用。

I had used react-slick 0.23.1 which it doesn't work 我使用过React-Slick 0.23.1,它不起作用

Later I tried with react-slick 0.21.0 it did work 后来我尝试使用react-slick 0.21.0确实有效

Thanks! 谢谢!

Give a reference to the tag. 引用标签。

<Slider ref={slider => (this.slider = slider)}>
 ...
</Slider>

You can use the slickPause() & slickPlay() functions 您可以使用slickPause()和slickPlay()函数

play() {
  this.slider.slickPlay();
}

pause() {
  this.slider.slickPause();
}

https://github.com/akiran/react-slick/blob/master/examples/AutoPlayMethods.js https://github.com/akiran/react-slick/blob/master/examples/AutoPlayMethods.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从父组件传递道具在子组件 React 中变为空 - Passing a prop from a Parent component becomes null in the Child component React React - 使用从父组件传递的道具渲染子组件时出错 - React - Error while rendering child component with prop passed from parent component 使用 React Hooks,当我将 prop 从父组件传递给子组件时,子组件中的 prop 未定义 - Using React Hooks, when I pass down a prop from parent to a child component, the prop in the child component is undefined 从父组件获取子组件 Prop - Getting Child Component Prop from the Parent Component 从其子项触发 React 父功能组件中的 function - Triggering a function in a React parent functional component from its child 如何从父组件 prop 访问子组件 prop - How to access the child component prop from parent component prop 目标容器不是DOM元素-React和GatsbyJS-React-slick组件 - Target container is not a DOM element - React and GatsbyJS - React-slick Component 从子组件访问父道具/属性 - Access parent prop / attribute from child component 将 prop 从父组件传递给子组件时出错 - Error with passing a prop from parent to child component ReactJS,将prop从父组件传递到子组件? - ReactJS, passing prop from parent to child component?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM