P粉1254505492023-08-15 11:23:01
Getter/Setter can be a little tricky with scope. The usual approach seems to be correct. Maybe try storing the entity in a data property and setting a listener on it.
data() { return { entity: this.element.config.entity.value, }; }, watch: { entity(value) { this.$emit('entity-picked', value); }, }, methods: { entityChanged(value) { this.element.config.entity.value = value; this.entity = value; }, },
renew
Or as a listener inside the component
component:
watch: { 'element.data.entityId': { handler() { this.entityId = this.element.data.entityId; }, deep: true, } }
The data can then be updated from configComponent
using:
computed: { myentity: { get() { return this.element.config.myEntity.value; }, set(value) { this.element.config.myentity.value = value; this.$set(this.element.data, 'entityId', value); this.$emit('element-update', this.element); } } },
Then, in the twig file of configComponent
, the myentity
method is used in the v-model## of
sw-entity-single-select #:
{% block sw_cms_element_team_box_config %} <sw-entity-single-select label="testing my entity" entity="myexample_entity" v-model="myentity" /> {% endblock %}