我正在为 vivus.js 库使用 react 组件,但不知道如何使用它的方法,例如,我想在幻灯片更改时调用 myVivus.play(),但不确定如何使用。我只是在学习反应,因为我知道我需要公开组件的方法才能在渲染中使用它,但到目前为止我所有的尝试都没有成功。任何帮助深表感谢!谢谢你。
import React from 'react';
import ReactVivus from 'react-vivus';
import ReactFullpage from '@fullpage/react-fullpage'
import Svg1 from './example.svg';
import Svg2 from './example2.svg';
const Anim1 = () => (
<ReactVivus
id="anim1"
option={{
file: Svg1,
animTimingFunction: 'EASE',
type: 'oneByOne',
onReady: console.log
}}
callback={console.log}
/>
);
const Anim2 = () => (
<ReactVivus
id="anim1"
option={{
file: Svg2,
animTimingFunction: 'EASE',
type: 'oneByOne',
onReady: console.log
}}
callback={console.log}
/>
);
const FullpageWrapper = fullpageProps => (
<div>
<SEO title="Home" />
<Menu>
<MenuContainer>Logo</MenuContainer>
</Menu>
<ReactFullpage
{...fullpageProps}
//fullpage options
licenseKey = {'***'}
navigation
anchors={['intro', 'reasonOne', 'reasonTwo']}
sectionsColor={['#4e5c9e', '#d3d7f2', '#F5F5F6']}
render={({ state, fullpageApi }) => {
return (
<div id="fullpage-wrapper">
<div className="section section1 light">
<SlideWrapper>
<TextBlock>
<SlideHeader>Header 1</SlideHeader>
<SlideDescription>Description text 1</SlideDescription>
</TextBlock>
<AnimationBlock>
<Anim1/>
<button onClick={() => this.play()} >Play</button>
</AnimationBlock>
</SlideWrapper>
</div>
<div className="section section2">
<SlideWrapper>
<AnimationBlock>
<Anim2/>
</AnimationBlock>
<TextBlock>
<SlideHeader>Header 2</SlideHeader>
<SlideDescription>>Description text 2</SlideDescription>
</TextBlock>
</SlideWrapper>
</div>
...
</div>
);
}}
/>
</div>
);
export default FullpageWrapper;