From f1e058428e5b68f4384137224f306477b7e71933 Mon Sep 17 00:00:00 2001 From: mtmsig Date: Fri, 9 Aug 2019 13:38:34 +0200 Subject: [PATCH] fields: input-select-search & input-file, fix reactive --- src/components/fields/input-file.vue | 17 +++++++++++------ src/components/fields/input-select-search.vue | 11 ++++++++--- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/components/fields/input-file.vue b/src/components/fields/input-file.vue index d7243632..70e35bcd 100644 --- a/src/components/fields/input-file.vue +++ b/src/components/fields/input-file.vue @@ -80,12 +80,17 @@ export default { } }, - created() { - if (this.url) { - this.fileList.push({ - url: this.url, - name: this.url.split("/").slice(-1)[0] - }); + watch: { + url: { + immediate: true, + handler(url) { + if (url) { + this.fileList.push({ + url: url, + name: url.split("/").slice(-1)[0] + }); + } + } } } }; diff --git a/src/components/fields/input-select-search.vue b/src/components/fields/input-select-search.vue index 6aeeb03b..687724f0 100644 --- a/src/components/fields/input-select-search.vue +++ b/src/components/fields/input-select-search.vue @@ -120,9 +120,14 @@ export default { }); } }, - created() { - if (this.value) { - this.getSelectedItem(); + watch: { + value: { + immediate: true, + handler(value) { + if (value && !this.selectedItem) { + this.getSelectedItem(); + } + } } } };