导览/Joyride整合到我的网站 [英] Guided Tour / Joyride Integration to my Website
问题描述
我想为我的React App添加一个操纵杆或导览.我想在用户第一次使用它时显示它,并禁用以后的频繁访问.我已经找到该库 https://github.com/gilbarbara/react-joyride ,但无法不知道如何禁用同一用户的后续访问?我可以使用本地存储或cookie来解决此问题吗?怎么样?
I want to add a joyride or guided tour for my React App. I want to show it when the users first uses it and disable for subsequent frequent visits. I have found this library https://github.com/gilbarbara/react-joyride but couldn't figure out how to disable on subsequent visits by same user? Can I use localstorage or cookies to deal with this issue? How?
推荐答案
是的,将其添加到localStorage是一个很好的解决方案.为此,我使用以下功能来触发检查:
Yes adding it to localStorage is a good solution. I use the following function for this to trigger the check:
checkForInitialTour() {
if (!localStorage.getItem('tourDone')) {
localStorage.setItem('tourDone', true);
this.joyride.reset();
this.joyride.start(true);
}
}
游览后还可以通过使用callback参数在本地存储中设置
Also possible to set in localstorage after tour by using the callback parameter
callback={(e) => { if (e.type === 'finished') { window.scrollTo(0, 0); localStorage.setItem('tourDone', true); } }}
这篇关于导览/Joyride整合到我的网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!