単一画像プレビュー付きアップロード「vue-img-inputer」
by kabanoki
HTML
<div id="app">
<img-inputer v-model="file"
theme="light"
size="large"
placeholder="ファイルをここにドラッグする"
bottom-text="ファイルをドロップするかここをクリックしてください" />
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.js"></script>
CSS
body {
background: #20262E;
padding: 20px;
font-family: Helvetica;
}
#app {
background: #fff;
border-radius: 4px;
padding: 20px;
transition: all 0.2s;
}
li {
margin: 8px 0;
}
h2 {
font-weight: bold;
margin-bottom: 15px;
}
del {
color: rgba(0, 0, 0, 0.3);
}
Vue
const ImgInputer = window['vueImgInputer'];
Vue.component('img-inputer', ImgInputer)
new Vue({
el: '#app',
data: {
file:''
}
});