我有一个带有rails的html代码。我需要将其转换为苗条格式,更改了文件格式,使用对流器进行了转换,并尝试运行它,结果链接无法正常工作,您能告诉我为什么吗?
head.html.erb
<section id="header">
<div class='navigation-panel'>
<button class='burger-button' id='header-burger-button container' onclick='burgerAction()'>
<%= image_tag("header/burger.png") %>
</button>
<button class='contact-us-button burger-hidable container' onclick='scroller("contact")'> CONTACT US </button>
<div class='menu-container burger-hidable container' style='display: none;'>
<%= image_tag("header/menu.png") %>
</div>
<div class='nav-links burger-hidable' style='display: none;'>
<p onclick='scroller("header")'>Home</p>
<p onclick='scroller("services")'>Services</p>
<p onclick='scroller("how-we-work")'>How We Work</p>
<p onclick='scroller("team")'>Team</p>
<p onclick='scroller("why-us")'>Why Us</p>
<p onclick='scroller("portfolio")'>Portfolio</p>
<p onclick='scroller("contact")'>Contact Us</p>
</div>
</div>
</section>
head.html.slim
section#header
.navigation-panel
button.burger-button id=("header-burger-button container") onclick="burgerAction()"
= image_tag("header/burger.png")
button.contact-us-button.burger-hidable.container onclick="scroller(\"contact\")" CONTACT US
.menu-container.burger-hidable.container style=("display: none;")
= image_tag("header/menu.png")
.nav-links.burger-hidable style=("display: none;")
p onclick="scroller(\"header\")" Home
p onclick="scroller(\"services\")" Services
p onclick="scroller(\"how-we-work\")" How We Work
p onclick="scroller(\"team\")" Team
p onclick="scroller(\"why-us\")" Why Us
p onclick="scroller(\"portfolio\")" Portfolio
p onclick="scroller(\"contact\")" Contact Us
答案 0 :(得分:1)
我认为问题在于onclick属性中的转义引号。
考虑在属性的双引号内使用单引号:onclick="scroller('header')"
。
您可以在此处阅读有关转义和引用属性的更多信息:https://www.rubydoc.info/gems/slim/frames#Output_without_HTML_escaping___