You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to make schema-form has stored data so that user can edit form-data whenever they want.
However once schema-form is created, I can't bind data through the method. ( I get the data from server through axios, and try to bind when vue page is created.)
plz check example below.
check image below.
as you can see in the image, data is binded after axios or click event, but the form is still empty and the data is removed when click submit button.
The text was updated successfully, but these errors were encountered:
The SchemaForm component was not designed to auto update when initial data is updated. The reason for this is that any user-entered data would be lost when the prop changes.
This could be a useful feature - given an appropriate merging strategy between the internal state (this.items) and any changes to the value prop - hence I'm marking this as a possible future enhancement.
For now, a workaround you can use is to wait for the AJAX request to finish before mounting the schema-form component:
I want to make schema-form has stored data so that user can edit form-data whenever they want.
However once schema-form is created, I can't bind data through the method. ( I get the data from server through axios, and try to bind when vue page is created.)
plz check example below.
<schema-form :schema="schema" v-model="obj" @submit="handleSubmit()" />
data () {
return {
schemaIsValid: true,
schema: baseSchema,
obj: {
"firstName": "11111",
"nickNames": [
{
"url": "111111111111",
"title": "1111111111111"
}
]
},
}
<schema-form :schema="schema" v-model="obj" @submit="handleSubmit()" />
<button type="button" class="button" @click="UpdateData()">Update form Data
data () {
return {
schemaIsValid: true,
schema: baseSchema,
obj: {}
}
},
methods: {
handleSubmit() {
console.log(JSON.stringify(this.obj, null, 2))
}
,UpdateData() {
this.obj = baseData;
}
}
<schema-form :schema="schema" v-model="obj" @submit="handleSubmit()" />
data () {
return {
schemaIsValid: true,
schema: baseSchema,
obj: {},
}
},
created() {
this.$http
.get(URL,{ headers: { 'Content-Type' : 'application/json'}})
.then( res => {
this.obj = JSON.parse(res.data..obj);
}
,function() {
console.log('failed')
});
},
The text was updated successfully, but these errors were encountered: