Shopware 6 sw-entity-single-select 空选项
Shopware 6 sw-entity-single-select empty options
我正在使用 <sw-entity-single-select
标签,但里面的项目是空的。项目的数量是正确的,console.log 数据变化也给出了正确的数据。也许我缺少某个属性或其他东西?
这是标签
<sw-entity-single-select
v-model="component.dimensionType"
entity="dimension"
:localMode="component.isNew()"
label="Koppel dimensie aan component"
@change="setDimension"
>
</sw-entity-single-select>
这是维度的实体定义
return new FieldCollection(
[
(new IdField('id', 'id'))->addFlags(new Required(), new PrimaryKey()),
(new StringField('title', 'title'))->addFlags(new Required()),
(new OneToManyAssociationField(
'components',
ComponentDefinition::class,
'dimension_type',
'id'))->addFlags(new RestrictDelete(), new ReverseInherited('dimensionType')
),
]
);
组件中的关系相反
new FkField('dimension_type', 'dimensionType', DimensionDefinition::class),
new ManyToOneAssociationField(
'dimension',
'dimension_type',
DimensionDefinition::class
),
我想您错过了指定每个项目文本的 labelProperty
属性。
如果您有一个自定义实体,Vue 不知道要取哪个 属性 作为名称。
因此,您必须在 sw-entity-single-select component.
提供的插槽中传递您的自定义名称
一个例子:
<sw-entity-single-select
v-model="component.dimensionType"
entity="dimension"
:localMode="component.isNew()"
label="Koppel dimensie aan component"
@change="setDimension">
<template #result-item="{ item, index }">
<slot name="result-item" v-bind="{ item, index }">
<li is="sw-select-result" v-bind="{ item, index }">
{{ item.title }}
</li>
</slot>
</template>
</sw-entity-single-select>
我正在使用 <sw-entity-single-select
标签,但里面的项目是空的。项目的数量是正确的,console.log 数据变化也给出了正确的数据。也许我缺少某个属性或其他东西?
这是标签
<sw-entity-single-select
v-model="component.dimensionType"
entity="dimension"
:localMode="component.isNew()"
label="Koppel dimensie aan component"
@change="setDimension"
>
</sw-entity-single-select>
这是维度的实体定义
return new FieldCollection(
[
(new IdField('id', 'id'))->addFlags(new Required(), new PrimaryKey()),
(new StringField('title', 'title'))->addFlags(new Required()),
(new OneToManyAssociationField(
'components',
ComponentDefinition::class,
'dimension_type',
'id'))->addFlags(new RestrictDelete(), new ReverseInherited('dimensionType')
),
]
);
组件中的关系相反
new FkField('dimension_type', 'dimensionType', DimensionDefinition::class),
new ManyToOneAssociationField(
'dimension',
'dimension_type',
DimensionDefinition::class
),
我想您错过了指定每个项目文本的 labelProperty
属性。
如果您有一个自定义实体,Vue 不知道要取哪个 属性 作为名称。 因此,您必须在 sw-entity-single-select component.
提供的插槽中传递您的自定义名称一个例子:
<sw-entity-single-select
v-model="component.dimensionType"
entity="dimension"
:localMode="component.isNew()"
label="Koppel dimensie aan component"
@change="setDimension">
<template #result-item="{ item, index }">
<slot name="result-item" v-bind="{ item, index }">
<li is="sw-select-result" v-bind="{ item, index }">
{{ item.title }}
</li>
</slot>
</template>
</sw-entity-single-select>