Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 反应驾驶乐趣-如何关闭教程时,点击十字架?_Reactjs - Fatal编程技术网

Reactjs 反应驾驶乐趣-如何关闭教程时,点击十字架?

Reactjs 反应驾驶乐趣-如何关闭教程时,点击十字架?,reactjs,Reactjs,我正在我的项目中使用react joyride。我将展示一个与此代码匹配的简单教程 <Tutorial steps={[ { target: `body`, title: `New on the website ? `, content: `To see how the website works, let's get started`, locale: {

我正在我的项目中使用react joyride。我将展示一个与此代码匹配的简单教程

<Tutorial
        steps={[
          {
            target: `body`,
            title: `New on the website ? `,
            content: `To see how the website works, let's get started`,
            locale: {
              next: `Start`, skip: `Skip`
            },
            disableBeacon: true,
            placement: `center`
          },
          {
            target: `#search-block .wrapper-city`,
            content: `Give us information about the city`,
            placement: `top`,
            disableBeacon: true
          },
          {
            target: `#search-block .wrapper-date-range`,
            content: `Tell us the period`,
            placement: `top`
          },
          {
            target: `#search-block .wrapper-activity-type`,
            content: `Tell us the activity you would like to practice`,
            placement: `top`
          },
          {
            target: `#search-block button.btn-green`,
            content: `Finally click search `,
            placement: `top`
          }
        ]}
        joyrideProps={{ disableScrolling: true }}
        callback={(data) => {
          console.log(data);
        }}
      />

我想你现在已经自己解决了这个问题。但是,如果有人可能遇到同样的问题,这个答案可能会有所帮助。react joyride的当前行为是关闭模态,但实际上杀死该实例

所以在我的例子中,我通过定义redux状态解决了这个问题,该状态切换了ReactJoyride

renderTutorial = () => {
    const { showTutorial } = this.props;
    return (
      <ReactJoyride
        callback={this.handleJoyrideCallback}
        continuous
        run={!!showTutorial}
        steps={scoringSteps}
        styles={{
          options: {
            zIndex: 1000,
            primaryColor: '#3698DC'
          }
        }}
      />
    )
};

handleJoyrideCallback = data => {
    if (action ===  'close') {
      this.props.endTutorial();
    }
};
rendertual=()=>{
const{showttutorial}=this.props;
返回(
)
};
handleJoyrideCallback=数据=>{
如果(操作=='close'){
this.props.endTutorial();
}
};
我重写了回调函数,并使用它来分派操作,从而更改显示Joyride的道具。因此,当我们将道具改为假的时候,我们就看不到这辆车了


仅供参考:操作===“关闭”将有助于检查是否单击了十字图标。

我认为您现在已经自己解决了问题。但是,如果有人可能遇到同样的问题,这个答案可能会有所帮助。react joyride的当前行为是关闭模态,但实际上杀死该实例

所以在我的例子中,我通过定义redux状态解决了这个问题,该状态切换了ReactJoyride

renderTutorial = () => {
    const { showTutorial } = this.props;
    return (
      <ReactJoyride
        callback={this.handleJoyrideCallback}
        continuous
        run={!!showTutorial}
        steps={scoringSteps}
        styles={{
          options: {
            zIndex: 1000,
            primaryColor: '#3698DC'
          }
        }}
      />
    )
};

handleJoyrideCallback = data => {
    if (action ===  'close') {
      this.props.endTutorial();
    }
};
rendertual=()=>{
const{showttutorial}=this.props;
返回(
)
};
handleJoyrideCallback=数据=>{
如果(操作=='close'){
this.props.endTutorial();
}
};
我重写了回调函数,并使用它来分派操作,从而更改显示Joyride的道具。因此,当我们将道具改为假的时候,我们就看不到这辆车了

仅供参考:操作===“关闭”将有助于检查是否单击了十字图标