- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
P5 JavaScript 与 HTML 集成并发布在 GitHub 上。通常,可以通过将两个参数添加到 HTML URL 来将它们传递到代码中。这在本地测试代码时有效。尝试使用旨在预览 HTML 页面的语法对 github 上的 HTML 页面执行此操作时失败。请注意,默认情况下,直接的 URL 将显示源代码,而不是 GitHub 项目上的工作 HTML 页面。这是设计使然。计划是使用此 URL 作为 readme.md 文件超链接的目标。这将为项目的访问者演示工作代码。
在查看此 StackOverflow post 后尝试了以下操作.这些尝试现在确实奏效了:
?
,如 ...\?runModeToggle=1&run...
?
之后的引号中,如 http://htmlpreview.github.com/?"https://github.com/... "
我的代码是为了学习目的而展示的,展示了它是如何演变的。在没有参数的情况下做更简单事情的早期迭代显示良好。例如:
但是对于需要参数才能工作的一种代码风格,这就是问题所在。 This post还建议尝试其他事情,但没有一个能解决问题。如果此 URL 正常工作,那么这两个参数将在页面的第二行文本中显示为相应的数字,并且当用户在页面上单击 (mousepressed
) 时,它们会导致某些行为:
最佳答案
原始文章中未提及,正在测试的代码在页面顶部输出 URL 参数以用于演示目的以及在代码中使用它们。从问题中测试此 URL 时:
请注意第二行如何显示第一个参数是“未定义”而另一个参数显示为“1”。我能够通过简单地在真实参数之前添加一个虚拟参数来解决这个问题。为什么会是这种情况目前未知,但它似乎可以解决问题:
为了查看代码与各种参数一起工作,修改后的 URL 现已添加到该项目主页上的自述文件中:
关于javascript - 超链接到 GitHub 项目 HTML 作为带有参数的预览,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49387367/
我是一名优秀的程序员,十分优秀!