如何在Sanity Studio中设置无线电按钮的默认值?
我正在尝试在Sanity Studio中设置默认值列表。
代码:
export default {
name: 'banner',
title: 'Banner',
type: 'document',
fields: [
{
name: "category",
title: "Category",
description: "Choose a category",
type: "string",
options: {
layout: "radio",
list: [
{ title: "Documentary", value: "documentary" },
{ title: "Fiction", value: "fiction" },
],
},
// set initial value here ?
},
]
}
有一个称为initialValue
的属性,可以轻松设置字符串的默认值,但是我不知道如何使用无线电项目来完成此操作。
如何将无线电项目Fiction
在加载页面时已选择?
I'm trying to set the default value given a list of radio items in Sanity Studio.
Code:
export default {
name: 'banner',
title: 'Banner',
type: 'document',
fields: [
{
name: "category",
title: "Category",
description: "Choose a category",
type: "string",
options: {
layout: "radio",
list: [
{ title: "Documentary", value: "documentary" },
{ title: "Fiction", value: "fiction" },
],
},
// set initial value here ?
},
]
}
There is a property called initialValue
that can set the default value of a string easily, but I can't figure out how to do this with radio items.
How can I have the radio item Fiction
already selected when the page is loaded?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试直接在文档对象上而不是在字段上使用
initialValue
:Try using
initialValue
directly on the document object rather than on the field: