简体   繁体   English

Yii2:如何将默认操作设置到 controller

[英]Yii2: how to set the default action into the controller

I know how to set the default controller/action into the configuration by the defaultRoute option我知道如何通过defaultRoute选项将默认控制器/动作设置到配置中

'defaultRoute'        => 'home/index'

But I don't how do it with the action into the current controller.但我不知道如何使用当前 controller 的操作。

Can anybody help me?有谁能够帮我?

I have found the solution.我找到了解决方案。

class MyController extends Controller {
     public $defaultAction = 'my-action';
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM