原始代码是:
= link_to page.info_page_link do
.price == "Gold: <br>#{page.entry_fee}"
.price.right == "Fee:<br>#{page.popular_price}"
.calendar == "Time:<br>#{page.popular_period}"
.clock == "Process:<br>#{page.hours}"
现在,我必须在此链接中添加一个target="_blank"
,我尝试:
= link_to target: '_blank', page.info_page_link do
.price == "Gold: <br>#{page.entry_fee}"
.price.right == "Fee:<br>#{page.popular_price}"
.calendar == "Time:<br>#{page.popular_period}"
.clock == "Process:<br>#{page.hours}"
但是浏览器显示“语法错误”。
答案 0 :(得分:-1)
是的,这是参数排序问题。
只需将目标哈希移动到下一个位置即可:
= link_to page.info_page_link, target: '_blank' do
.price == "Gold: <br>#{page.entry_fee}"
.price.right == "Fee:<br>#{page.popular_price}"
.calendar == "Time:<br>#{page.popular_period}"
.clock == "Process:<br>#{page.hours}"
然后它起作用了!这是API文档:
https://api.rubyonrails.org/v5.2.0/classes/ActionView/Helpers/UrlHelper.html