javascript - vue element-ui 上傳文件組件怎么使用
問題描述
請問element-ui的上傳組件怎么使用,最好有demo可以看一下,官網(wǎng)的實(shí)在沒看懂!謝謝了
問題解答
回答1:<el-upload action='//jsonplaceholder.typicode.com/posts/' :on-preview='handlePreview' :on-remove='handleRemove' :file-list='fileList'> <el-button size='small' type='primary'>點(diǎn)擊上傳</el-button> <p slot='tip' class='el-upload__tip'>只能上傳jpg/png文件,且不超過500kb</p></el-upload><script> export default { data() { return {fileList: [{name: ’food.jpeg’, url: ’https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100’}, {name: ’food2.jpeg’, url: ’https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100’}] }; }, methods: { handleRemove(file, fileList) {console.log(file, fileList); }, handlePreview(file) {console.log(file); } } }</script>
官網(wǎng)的代碼直接用,然后在后臺(tái)接口去接受處理文件不久ok了嗎
相關(guān)文章:
1. Docker for Mac 創(chuàng)建的dnsmasq容器連不上/不工作的問題2. docker安裝后出現(xiàn)Cannot connect to the Docker daemon.3. javascript - 請教空白文本節(jié)點(diǎn)的問題4. javascript - 用js實(shí)現(xiàn)遠(yuǎn)程js調(diào)用時(shí)出現(xiàn)時(shí)間機(jī)制問題怎樣解決?5. 刷新頁面出現(xiàn)彈框6. javascript - 前端開發(fā) 本地靜態(tài)文件頻繁修改,預(yù)覽時(shí)的緩存怎么解決?7. ios - 類似微博首頁,一張圖的時(shí)候是如何確定圖大小的?8. java報(bào)錯(cuò)Communications link failure 該如何解決?9. javascript - 怎么看網(wǎng)站用了什么技術(shù)框架?10. PC 手機(jī)兼容的 編輯器
