|
| 1 | +<template> |
| 2 | + <div class="components"> |
| 3 | + <h3>Custom Component</h3> |
| 4 | + <p><code>class</code> will be bind to the component and you can include any child component.</p> |
| 5 | + <h4>Demo</h4> |
| 6 | + <p>This is a image upload button.</p> |
| 7 | + <p class="user center"> |
| 8 | + <img class="avatar" :src="src" /> |
| 9 | + </p> |
| 10 | + <div class="center"> |
| 11 | + <vue-core-image-upload |
| 12 | + :crop="false" |
| 13 | + @imageuploaded="imageuploaded" |
| 14 | + :data="data" |
| 15 | + :max-file-size="5242880" |
| 16 | + url="http://101.198.151.190/api/upload.php" > |
| 17 | + <img width="150" src="http://img1.vued.vanthink.cn/vuededa653aa59d1a1287d9a6e18890a7e51.png" /> |
| 18 | + </vue-core-image-upload> |
| 19 | + </div> |
| 20 | + <p>Code Example</p> |
| 21 | + <pre v-highlightjs><code class="javascript"><vue-core-image-upload |
| 22 | + :crop="false" |
| 23 | + @imageuploaded="imageuploaded" |
| 24 | + :data="data" |
| 25 | + :max-file-size="5242880" |
| 26 | + url="http://101.198.151.190/api/upload.php" > |
| 27 | + <img width="150" src="http://img1.vued.vanthink.cn/vuededa653aa59d1a1287d9a6e18890a7e51.png" /> |
| 28 | + </vue-core-image-upload> |
| 29 | + </code></pre> |
| 30 | + </div> |
| 31 | +</template> |
| 32 | + |
| 33 | +<style> |
| 34 | +
|
| 35 | +.avatar { |
| 36 | + width: 150px; |
| 37 | + height: 150px; |
| 38 | + margin-bottom: 20px; |
| 39 | + border-radius: 50%; |
| 40 | + border: 2px solid rgba(0,0,0,.05); |
| 41 | +} |
| 42 | +</style> |
| 43 | + |
| 44 | +<script> |
| 45 | +import VueCoreImageUpload from 'vue-core-image-upload' |
| 46 | +
|
| 47 | +export default { |
| 48 | + components: { |
| 49 | + 'vue-core-image-upload': VueCoreImageUpload, |
| 50 | + }, |
| 51 | + data() { |
| 52 | + return { |
| 53 | + src: 'http://img1.vued.vanthink.cn/vued0a233185b6027244f9d43e653227439a.png', |
| 54 | + } |
| 55 | + }, |
| 56 | + methods: { |
| 57 | + imageuploaded(res) { |
| 58 | + if (res.errcode == 0) { |
| 59 | + this.src = res.data.src; |
| 60 | + } |
| 61 | + } |
| 62 | + } |
| 63 | +}; |
| 64 | +
|
| 65 | +</script> |
0 commit comments