问题很简单,
我尝试使用以下代码生成与 Html 帮助程序的链接:
echo $this->Html->link('<span>PDF</span>', array('action' => 'index', 'ext' => 'pdf'));
echo $this->Html->link('<span>PDF</span>', array('action' => 'index', 'ext' => 'pdf', 'full_base' => true));
它生成:
<a href="/users.pdf" class="action pdf-action"><span>PDF</span></a>
因此,如果操作是索引,Cake 自己决定不在 url 中生成 /index,并且文档中没有选项可以避免这种情况。
有人知道我能做什么吗?
谢谢指教。
编辑:
我尝试使用路由器生成 url,结果相同:
echo $this->Html->link('<span>PDF</span>', Router::url(array('controller' => 'users', 'action' => 'index', 'ext' => 'pdf'), true), array('class' => 'action pdf-action', 'escape' => false));