如何用纯javascript控制眼镜呈现?
how to control spectacle presentation with pure javascript?
我试图获取所有幻灯片的数量并使用普通 javascript 更改为其中一张。我不喜欢做出反应,也找不到全局对象来调用某些函数。
是否有类似的东西:presentation.loadSlide(2);
?
来自docs,
The GoToAction tag lets you jump to another slide in your deck. The GoToAction can be used a simple button that supports Base styling or accept a render prop with a callback to support custom components
以下代码将呈现一个按钮,该按钮将跳转到幻灯片中的特定幻灯片。
<GoToAction slide={3}>Jump to 3</GoToAction>
请添加对您的 Deck
组件的引用,如下所示
<Deck ref={(deck) => {this.deck = deck; }} transition={["zoom", "slide"]} transitionDuration={500} theme={theme}>
...
</Deck>
现在您的组件中有一个名为 deck
的 属性。使用 componentDidMount
生命周期方法检索 this.deck.props.children.length
并将其分配给 window.slideCount
.
componentDidMount() {
window.slideCount = this.deck.props.children.length
}
现在打开浏览器控制台并输入 slideCount
,您会看到那里显示了幻灯片计数。之后您可以使用以下内容更改幻灯片
window.location = "#/1"
我试图获取所有幻灯片的数量并使用普通 javascript 更改为其中一张。我不喜欢做出反应,也找不到全局对象来调用某些函数。
是否有类似的东西:presentation.loadSlide(2);
?
来自docs,
The GoToAction tag lets you jump to another slide in your deck. The GoToAction can be used a simple button that supports Base styling or accept a render prop with a callback to support custom components
以下代码将呈现一个按钮,该按钮将跳转到幻灯片中的特定幻灯片。
<GoToAction slide={3}>Jump to 3</GoToAction>
请添加对您的 Deck
组件的引用,如下所示
<Deck ref={(deck) => {this.deck = deck; }} transition={["zoom", "slide"]} transitionDuration={500} theme={theme}>
...
</Deck>
现在您的组件中有一个名为 deck
的 属性。使用 componentDidMount
生命周期方法检索 this.deck.props.children.length
并将其分配给 window.slideCount
.
componentDidMount() {
window.slideCount = this.deck.props.children.length
}
现在打开浏览器控制台并输入 slideCount
,您会看到那里显示了幻灯片计数。之后您可以使用以下内容更改幻灯片
window.location = "#/1"