|
| 1 | +<template> |
| 2 | + <div class="components"> |
| 3 | + <h3>Custom Events</h3> |
| 4 | + <p>It defines different custom event in different upload progress. You can control the files flow via binding some functions.</p> |
| 5 | + <h5>imageuploaded</h5> |
| 6 | + <p>When image has been uploaded, it call the function you bind. You could recive response from server as an param</p> |
| 7 | + <h5>imagechanged</h5> |
| 8 | + <p>When input[file] velue has been changed, it call the function you bind. You could recive an file source param</p> |
| 9 | + <h5>imageuploading</h5> |
| 10 | + <p>When the image is uploading.</p> |
| 11 | + <h5>errorhandle</h5> |
| 12 | + <p>Whne you meet some error like network error or file size error.</p> |
| 13 | + <h5>Code Example</h5> |
| 14 | + <div class="center"> |
| 15 | + <img class="avatar" :src="src" /> |
| 16 | + </div> |
| 17 | + <div class="center"> |
| 18 | + <vue-core-image-upload |
| 19 | + :class="['btn', 'btn-primary']" |
| 20 | + :crop="false" |
| 21 | + @imagechanged="imagechanged" |
| 22 | + @imageuploading="imageuploading" |
| 23 | + @imageuploaded="imageuploaded" |
| 24 | + :max-file-size="5242880" |
| 25 | + url="http://101.198.151.190/api/upload.php" > |
| 26 | + </vue-core-image-upload> |
| 27 | + </div> |
| 28 | + <div> |
| 29 | + <table class="m-table bordered"> |
| 30 | + <thead> |
| 31 | + <tr> |
| 32 | + <th>Selected</th> |
| 33 | + <th>Uplaoding</th> |
| 34 | + <th>Finished</th> |
| 35 | + </tr> |
| 36 | + </thead> |
| 37 | + <tbody> |
| 38 | + <tr> |
| 39 | + <td> |
| 40 | + <span class="circle-bar" :class="{'active': step>0}"></span> |
| 41 | + </td> |
| 42 | + <td><span class="circle-bar" :class="{'active': step>1}"></span></td> |
| 43 | + <td><span class="circle-bar" :class="{'active': step>2}"></span></td> |
| 44 | + </tr> |
| 45 | + </tbody> |
| 46 | + </table> |
| 47 | + </div> |
| 48 | + <p>Code:</p> |
| 49 | + <pre v-highlightjs><code class="html"><vue-core-image-upload |
| 50 | + :class="['btn', 'btn-primary']" |
| 51 | + :crop="false" |
| 52 | + @imagechanged="imagechanged" |
| 53 | + @imageuploading="imageuploading" |
| 54 | + @imageuploaded="imageuploaded" |
| 55 | + :max-file-size="5242880" |
| 56 | + url="http://101.198.151.190/api/upload.php" > |
| 57 | +</vue-core-image-upload></code></pre> |
| 58 | + <pre v-highlightjs><code class="javascript">methods: { |
| 59 | + imagechanged() { |
| 60 | + this.step += 1; |
| 61 | + }, |
| 62 | + |
| 63 | + imageuploading() { |
| 64 | + this.step += 1; |
| 65 | + }, |
| 66 | + |
| 67 | + imageuploaded(res) { |
| 68 | + this.step += 1; |
| 69 | + this.src = res.data.src; |
| 70 | + } |
| 71 | + }</code></pre> |
| 72 | + <a href="">View code source</a> |
| 73 | + </div> |
| 74 | +</template> |
| 75 | + |
| 76 | +<style> |
| 77 | + .circle-bar{ |
| 78 | + display: inline-block; |
| 79 | + width: 20px; |
| 80 | + height: 20px; |
| 81 | + border-radius: 10px; |
| 82 | + background-color: #999; |
| 83 | + } |
| 84 | + .circle-bar.active{ |
| 85 | + background-color: #2ecc71; |
| 86 | + } |
| 87 | +</style> |
| 88 | + |
| 89 | +<script> |
| 90 | +import VueCoreImageUpload from '../../../../src/vue-core-image-upload.vue' |
| 91 | +export default { |
| 92 | + components: { |
| 93 | + VueCoreImageUpload, |
| 94 | + }, |
| 95 | +
|
| 96 | + data() { |
| 97 | + return { |
| 98 | + src: 'http://img1.vued.vanthink.cn/vued0a233185b6027244f9d43e653227439a.png', |
| 99 | + step: 0, |
| 100 | + } |
| 101 | + }, |
| 102 | +
|
| 103 | + methods: { |
| 104 | + imagechanged() { |
| 105 | + this.step += 1; |
| 106 | + }, |
| 107 | + imageuploading() { |
| 108 | + this.step += 1; |
| 109 | + }, |
| 110 | +
|
| 111 | + imageuploaded(res) { |
| 112 | + this.step += 1; |
| 113 | + this.src = res.data.src; |
| 114 | + } |
| 115 | + } |
| 116 | +} |
| 117 | +</script> |
0 commit comments