javascript - vue element-ui 上傳文件組件怎么使用
問題描述
請問element-ui的上傳組件怎么使用,最好有demo可以看一下,官網的實在沒看懂!謝謝了
問題解答
回答1:<el-upload action='//jsonplaceholder.typicode.com/posts/' :on-preview='handlePreview' :on-remove='handleRemove' :file-list='fileList'> <el-button size='small' type='primary'>點擊上傳</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>
官網的代碼直接用,然后在后臺接口去接受處理文件不久ok了嗎
相關文章:
1. angular.js - angular ng-class里面的引號問題2. python - 為什么在main()函數里result 會變成那樣?3. javascript - Web微信聊天輸入框解決方案4. docker - 如何修改運行中容器的配置5. css - 對于類選擇器使用的問題6. html - vue項目中用到了elementUI問題7. 網頁爬蟲 - 用Python3的requests庫模擬登陸Bilibili總是提示驗證碼錯誤怎么辦?8. javascript - 有沒有什么好的圖片懶加載的插件,需要包含監聽頁面滾動高度,然后再加載的功能9. javascript - es6將類數組轉化成數組的問題10. mysql無法添加外鍵
