Skip to content
This repository has been archived by the owner on Nov 15, 2018. It is now read-only.

Commit

Permalink
fix(components): 修复单向数据绑定问题
Browse files Browse the repository at this point in the history
  • Loading branch information
mutoe committed Jul 12, 2018
1 parent d12c2bb commit fb42d42
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/components/ImagePoster.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<template>
<div
:class="{ loading: poster.loading, error: poster.error }"
:class="{ loading: posterInternal.loading, error: posterInternal.error }"
class="m-box m-aln-center m-justify-center m-poster-box"
@click="addPoster">
<img
v-if="poster.src"
:src="poster.src"
v-if="posterInternal.src"
:src="posterInternal.src"
class="m-poster"
@load.stop="loadedPoster(poster)"
@load.stop="loadedPoster(posterInternal)"
@error="posterError">
<div
v-else
Expand All @@ -20,7 +20,7 @@
<slot/>
</div>
<div
v-if="!poster.error && poster.loading"
v-if="!posterInternal.error && posterInternal.loading"
class="fixed-loading">
<div
class="u-loading"
Expand Down Expand Up @@ -92,9 +92,14 @@ export default {
*/
poster: { type: Object, default: () => defaultPoster }
},
data() {
return {
posterInternal: this.poster // for one-way data binding
};
},
methods: {
addPoster() {
if (this.poster.loading) return;
if (this.posterInternal.loading) return;
this.$refs.imagefile.click();
},
selectPhoto() {
Expand All @@ -106,7 +111,7 @@ export default {
type: files[0].mimeType,
src: window.URL.createObjectURL(files[0])
};
this.poster = Object.assign({}, defaultPoster, posterObj);
this.posterInternal = Object.assign({}, defaultPoster, posterObj);
}
},
/**
Expand Down
2 changes: 2 additions & 0 deletions src/page/profile/Certificate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,12 @@ export default {
},
poster1() {
const id = this.fields.files[0];
if (!id) return;
return { id, src: `${this.$http.defaults.baseURL}/files/${id}?w=600` };
},
poster2() {
const id = this.fields.files[1];
if (!id) return;
return { id, src: `${this.$http.defaults.baseURL}/files/${id}?w=600` };
}
},
Expand Down

0 comments on commit fb42d42

Please sign in to comment.