关闭。这个问题需要details or clarity .它目前不接受答案。
想改善这个问题吗?通过 editing this post 添加详细信息并澄清问题.
7年前关闭。
Improve this question
嗨,我不会渲染带有 anchor 位置的 View - http://example.com/index.php#top
可能是这样的:
$this->render('index', ['data' => $data], 'anchor'=>'top');
有任何想法吗?
最佳答案
当您拨打 render
网址已设置,因为您在 controller
(或 view
)。所以此时你不能在url中添加 anchor 。
您必须在调用 Controller 之前设置 anchor 。为此,您可以在创建 url 时设置一个 anchor :
$this->createUrl('controller/action', array('#' => 'the-anchor'));
您也可以使用
redirect
将访问者重定向到带有 anchor 的页面$this->redirect(array('controller/action', array('#' => 'the-anchor')));
但我认为在创建 url 时设置 anchor 是实现您想要的最佳方式。
关于html - 如何使用 render() Yii 将 anchor 发送到 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23336330/