keystonejs 根据选择另一个 select 选项显示 select 选项

keystonejs display select option depending on choosing another select option

我正在尝试在 keystone.js 应用程序模型中从 select 选项中选择与用户在另一个 select 选项中选择的内容相关的内容.. 所以他会选择第一个,第二个 select 选项应该有只与第一个 selected 选项相关的数据.. 我希望有一个人可以帮助我 非常感谢

您应该使用 dependsOn 选项。

示例..

type: { type: Types.Select, options: ['TypeOne','TypeTwo','TypeThree TypeFour' ], initial: true },

something: { type: Types.Text, dependsOn: { type: 'TypeThree' }, initial: true },

关系示例 - 您可以按照逻辑显示某些字段仅在 dependsOn 条件匹配时显示。

Adjustment.add({
type: { type: Types.Select, options: ['Booking','Shipment','Warehouse','Inventory' ], initial: true },
sku: { type: Types.Text, initial: true },
quantity: { type: Types.Number, initial: true, width: 'short' },
keyID: { type: Types.Relationship, ref: 'Order', dependsOn: { type: 'Booking' }, initial: true },
bookingID: { type: Types.Relationship, ref: 'Booking', dependsOn: { type: 'Booking' }, initial: true },
warehouse: { type: Types.Relationship, ref: 'Warehouse', dependsOn: { type: 'Warehouse' }, initial: true },
shipmentID: { type: Types.Text, dependsOn: { type: 'Shipment' }, initial: true },

});