我在我的网站上使用Typed.js循环一串关于志愿服务的引用。当我看到它在运行时,一切都在正常工作。直到带分号的引号出现为止。当它输入它时,一切都很好,但是当它不键入它时,它会正常地取消它,直到它到达分号为止。当它到达分号,它只是完全删除整行,而不是继续动画的取消它。
这是我的密码:
var data = {
strings: ["“<i>As you grow older, you will discover that you have two hands — one for helping yourself; the other for helping others.</i>” — Audrey Hepburn", "“<i>Never doubt that a small group of thoughtful, committed citizens can change the world; indeed, it’s the only thing that ever has.</i>” – Margaret Mead", "“<i>The best way to find yourself is to lose yourself in the service of others.</i>” – Gandhi", "“<i>Volunteering is at the very core of being a human. No one has made it through life without someone else’s help.</i>” – Heather French Henry", "“<i>Volunteerism is the voice of the people put into action. These actions shape and mold the present into a future of which we can all be proud.</i>” – Helen Dyer"],
typeSpeed: 40,
backSpeed: 20,
shuffle: true,
loop: !0
};
new Typed('.animated-text', data);这里有一个小视频来证明这一点:
https://im3.ezgif.com/tmp/ezgif-3-425cf91d8c.gif
正如您在gif中所看到的那样,带分号的引号键入得很好,但是当它返回或取消类型时,它不会取消类型,直到分号并删除该行。当它继续下一个引号时,一个没有分号的引号,它的类型和类型都很好。
我的问题是,为什么会发生这种情况,以及如何解决这个问题。
谢谢!如有任何回应,敬请谅解!
发布于 2022-01-07 20:03:01
您可以通过编码分号(它是html实体变体; )来解决这个问题。
这是因为typed.js看到分号并试图将该分号之前的字符解析为html实体,而且由于没有符号并指示这样一个html实体的开始,所以它删除了字符串的其余部分。
var data = {
strings: ["“<i>As you grow older, you will discover that you have two hands — one for helping yourself; the other for helping others.</i>” — Audrey Hepburn", "“<i>Never doubt that a small group of thoughtful, committed citizens can change the world; indeed, it’s the only thing that ever has.</i>” – Margaret Mead", "“<i>The best way to find yourself is to lose yourself in the service of others.</i>” – Gandhi", "“<i>Volunteering is at the very core of being a human. No one has made it through life without someone else’s help.</i>” – Heather French Henry", "“<i>Volunteerism is the voice of the people put into action. These actions shape and mold the present into a future of which we can all be proud.</i>” – Helen Dyer"],
typeSpeed: 40,
backSpeed: 20,
loop: !0
};
new Typed('.animated-text', data);https://stackoverflow.com/questions/70625811
复制相似问题