【发布时间】:2019-12-13 20:18:29
【问题描述】:
我在其中一个组件中添加了如下 Intro.js:
import introJs from 'intro.js';
然后在componentDidMount中调用它
componentDidMount() {
introJs().start();
}
我在哪里使用它的元素:
<div className={cx('dropDownSortingBlock')}>
{!isTrending && <div className={cx('dropDown')} data-intro={'Hello step one!'}>
但是,当我将 css 导入父组件时
它不渲染组件。
更新:
我尝试使用 intro.js react wrapper,现在我已将 css 直接导入到我的文件中。
但它不起作用
constructor() {
super();
this.state = {
showMessage: false,
type: '',
message: '',
stepsEnabled: true,
initialStep: 0,
steps: [
{
element: '.snapshotWrapper',
intro: 'Hello step',
},
{
element: '.snapshotWrapperNew',
intro: 'Hello Sort wrapper',
},
],
};
}
渲染中
<Steps
enabled={this.state.stepsEnabled}
steps={this.state.steps}
initialStep={this.state.initialStep}
onExit={this.onExit}
/>
下面是显示的内容:
【问题讨论】:
-
doesn't render表示该组件根本不存在于 DOM 中,或者您根本看不到它? -
组件存在 @AdamKosmala 没有应用 css
-
我会验证
ListLandingPage.css是否在任何地方加载,以及导入的文件是否在您的 css 包中可用。我不熟悉 introJs,但也可以尝试用import * as introJs from 'intro.js'替换您的导入 -
@vini 请在他们的 github 上提出这个问题
-
@vini 我假设您正在使用 webpack?如果是这样,您的配置是什么?
标签: javascript reactjs intro.js