加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 如何使按钮在erb中作为链接工作?

发布时间:2020-12-17 04:36:07 所属栏目:百科 来源:网络整理
导读:%= link_to 'New Post',new_post_path % 这会生成到new_post_path的链接.以前我使用 input type =“submit”class =“new”name =“Addlist”value =“Add New”/它就像一个按钮.那么如何让链接看起来像erb中的按钮? 解决方法 只是为了抛出另一个选项,因为
<%= link_to 'New Post',new_post_path %>

这会生成到new_post_path的链接.以前我使用< input type =“submit”class =“new”name =“Addlist”value =“Add New”/>它就像一个按钮.那么如何让链接看起来像erb中的按钮?

解决方法

只是为了抛出另一个选项,因为我有一个button_to选项不起作用的场景.这看起来有点类似.
<%= link_to '<button type="button">New Post</button>'.html_safe,new_post_path %>

我基本上想要的是一个不会变成提交的按钮,因为我在页面上有多个与表单无关的按钮,我真的只想让它转到另一个页面.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读