我正在尝试使用spectacle-code-slide进行演示。目前我还不能让它渲染任何东西。以下是我所做的工作:
2将默认的/presentation/index.js替换为spectacle code -slide的"Usage“部分的代码,即(1)
import React from 'react';
import { Spectacle, Deck } from 'spectacle';
import CodeSlide from 'spectacle-code-slide';
export default class Presentation extends React.Component {
render() {
return (
<Spectacle theme={theme}>
<Deck transition={[]} transitionDuration={0} progress="bar">
// ...
<CodeSlide
transition={[]}
lang="js"
code={require("raw!../assets/code.example")}
ranges={[
{ loc: [0, 270], title: "Walking through some code" },
{ loc: [0, 1], title: "The Beginning" },
{ loc: [1, 2] },
{ loc: [1, 2], note: "Heres a note!" },
{ loc: [2, 3] },
{ loc: [4, 7] },
{ loc: [8, 10] },
// ...
]}/>
// ...
</Deck>
</Spectacle>
);
}
}3运行npm install,然后运行npm install --save spectacle-code-slide。
%4已将(%1)添加到assets/code.example。
5运行npm start。
我得到了:
Listening at http://localhost:3000
webpack built 966ffe50dc640fdaec4a in 4726ms已检查localhost:3000,但只有一个空白页。未报告其它错误。怎么一回事?
发布于 2016-06-14 09:33:02
嗯,你不能简单地替换整个文件。您应该只更改重要的部分,即render方法。当然,还要导入组件。
例如,如果您确实替换了整个文件,则甚至没有声明theme变量。
你可以在这里看到一个工作的例子
https://github.com/andrejunges/react-presentation/blob/master/presentation/index.js
https://stackoverflow.com/questions/37800547
复制相似问题