我看了下Yii::$app->authManager里面的方法有个叫
update($name, $object);
* @param string $name the old name of the role, permission or rule
后来我测试按照上面所说应该这么写才可以
public function actionEditrole($name)
{
if (Yii::$app->request->isPost) {
$authManager = Yii::$app->authManager;
$post=Yii::$app->request->post();
$role = $authManager->getRole($name);
$role->name = $post['name'];
$authManager->update($name,$role);//$name指的是老名字
return '编辑角色成功';
}
}