首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在Intro.js和Intro.js-react中,第一和第二步的位置不正确

在Intro.js和Intro.js-react中,第一和第二步的位置不正确
EN

Stack Overflow用户
提问于 2022-08-08 11:22:59
回答 1查看 245关注 0票数 0

问题是这样的。

当重新加载,第一步和弹出显示在左上角而不是中间,这是我的第一个问题。我希望它能像Intro.js官方文件所说的那样定位中心。

接下来,当你按下“下一步”时,弹出的东西会咬到左上角,我们看不见它。这是第二个问题。

此外,当按下"Next“时,弹出也会咬到左上角,我们看不到它。这也是第二个问题。

但是,当按下“下一步”时,弹出就会出现在正常的预期位置上。

当您再次按下“下一步”时,弹出仍将显示在正常的预期位置上。

代码看起来是这样的。

代码语言:javascript
运行
复制
import dynamic from 'next/dynamic';
import { useState } from 'react';

// Intro.js, see the details here: https://introjs.com/
// Intro.js-react, see the details here: https://github.com/HiDeoo/intro.js-react
// @ts-ignore
const Steps = dynamic(() => import('intro.js-react').then((mod) => mod.Steps), {
  ssr: false
});

const Onboarding = () => {
  const [stepEnabled, setStepEnabled] = useState(true);
  const steps = [
    {
      title: 'Welcome!!',
      intro:
        'This is your dashboard. Once you have set up, numbers will be displayed.'
    },
    {
      element: '#user-settings',
      title: 'User Settings page',
      intro: 'You can jump to the User Settings page from here.',
      position: 'right'
    },
    {
      element: '#profile-list',
      intro: 'This is your profile list.',
      position: 'right'
    },
    {
      element: '#card-list',
      intro: 'This is your card list.',
      position: 'left'
    }
  ];
  const onExit = () => {
    setStepEnabled(true);
  };
  const options = {
    showProgress: true,
    showBullets: true,
    exitOnOverlayClick: true,
    exitOnEsc: true,
    nextLabel: 'Next',
    prevLabel: 'Prev',
    // skipLabel: 'Skip',
    hidePrev: true,
    doneLabel: 'Done',
    overlayOpacity: 0.5,
    overlayColor: '#000',
    showStepNumbers: true,
    keyboardNavigation: true,
    scrollToElement: true,
    helperElementPadding: 10,
    showButtons: true
  };

  // if (!stepEnabled) {
  //   return null;
  // }
  return (
    <Steps
      // @ts-ignore
      enabled={stepEnabled}
      steps={steps}
      initialStep={0}
      onExit={onExit}
      options={options}
    />
  );
};

export default Onboarding;

有谁知道为什么和如何修复它吗?

EN

回答 1

Stack Overflow用户

发布于 2022-08-08 11:41:45

您可以向intro.js中的每个对象提供定制的css类,如下所示:()

代码语言:javascript
运行
复制
{
  element: ".test",
  intro: "",
  tooltipClass: "cssClassName1",
  tooltipPosition: "bottom-center",
},
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73277077

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档