首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Typed.js分号故障

Typed.js分号故障
EN

Stack Overflow用户
提问于 2022-01-07 18:45:23
回答 1查看 62关注 0票数 0

我在我的网站上使用Typed.js循环一串关于志愿服务的引用。当我看到它在运行时,一切都在正常工作。直到带分号的引号出现为止。当它输入它时,一切都很好,但是当它不键入它时,它会正常地取消它,直到它到达分号为止。当它到达分号,它只是完全删除整行,而不是继续动画的取消它。

这是我的密码:

代码语言:javascript
复制
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中所看到的那样,带分号的引号键入得很好,但是当它返回或取消类型时,它不会取消类型,直到分号并删除该行。当它继续下一个引号时,一个没有分号的引号,它的类型和类型都很好。

我的问题是,为什么会发生这种情况,以及如何解决这个问题。

谢谢!如有任何回应,敬请谅解!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-01-07 20:03:01

您可以通过编码分号(它是html实体变体&#59; )来解决这个问题。

这是因为typed.js看到分号并试图将该分号之前的字符解析为html实体,而且由于没有符号并指示这样一个html实体的开始,所以它删除了字符串的其余部分。

符号和半(不正确)解析为html实体的例子

你的例子

代码语言:javascript
复制
var data = {
  strings: ["“<i>As you grow older, you will discover that you have two hands — one for helping yourself&#59; the other for helping others.</i>” — Audrey Hepburn", "“<i>Never doubt that a small group of thoughtful, committed citizens can change the world&#59; 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);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70625811

复制
相关文章

相似问题

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