gpt4 book ai didi

keystonejs - Keystone js动态选择字段

转载 作者:行者123 更新时间:2023-12-05 07:02:04 24 4
gpt4 key购买 nike

我使用了 Select 字段,但使用手动选择选项创建。我有类别列表,我想创建另一个包含类别字段的列表。我想通过将所有类别提取到我的 Select 字段来选择我想要的类别。我怎样才能做到这一点?提前致谢!

const { Text, Select } = require('@keystonejs/fields');
const {Keystone} = require('@keystonejs/keystone');
const options = [
{ value: 'YES', label: "Yes, I'll be there!" },
{ value: 'NO', label: "Sorry, I can't make it :(" },
{ value: 'MAYBE', label: 'Not sure yet' },
];




module.exports={
fields:{
levels:{
type:Select,
options,
isRequired:true

},
tm: {
type: Text,
isRequired:true,
isUnique:true,


},
ru: {
type: Text,
isRequired:true,
isUnique:true,

},
en: {
type: Text,
isRequired:true,
isUnique:true,

},

},


}

最佳答案

我相信这个问题(和答案)可能对您有用:Dynamic type select in keystonejs model .对我来说。

简而言之,您可以为options 使用函数而不是数组。该函数为 options 返回一个数组。

关于keystonejs - Keystone js动态选择字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63687942/

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