gpt4 book ai didi

html - 如何使用 render() Yii 将 anchor 发送到 URL

转载 作者:行者123 更新时间:2023-12-04 12:52:32 26 4
gpt4 key购买 nike

关闭。这个问题需要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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com