我想通过viewbag将value字段的名称和text字段传递到我的下拉列表中。这是我的代码:
use Illuminate\Auth\Passwords\CanResetPassword as CanResetPasswordTrait;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordInterface;
use Illuminate\Notifications\Notifiable;
class User extends Model implements CanResetPasswordInterface
{
use CanResetPasswordTrait;
use Notifiable;
...
}
如何从Viewbag动态传递此参数?
答案 0 :(得分:0)
我认为您遇到了问题,因为keyField是字符串,而不是表示对象的属性。
尝试使用此方法获取keyField
item[keyField]
这是JSON的示例
{
value: item[keyField] ,
text: item[textField]
}
即使问题略有不同,我仍以此为参考: