vxe-table?使用?vxe-upload?在表格中實現(xiàn)非常強大的粘貼上傳圖片和附件功能
看看 vxe-table 渲染器強大到什么地步;在開發(fā)需求中,經(jīng)常會在表格列表中放入圖片展示,例如頭像、視頻圖片,附件列表等,但需要對表格批量操作是,會比較繁瑣,那么有沒有方便操作一點的放呢,肯定是有的;
配合 vxe-upload 上傳;比如復制或者截圖一張圖片,通過粘貼方式快速粘貼到單元格中,能支持單張、多張、查看、預覽。上傳精進度等。
官網(wǎng):https://vxetable.cn
渲染 vxe-upload,實現(xiàn)粘貼、拖拽上傳
<template> <div> <vxe-grid v-bind="gridOptions"></vxe-grid> </div> </template> <script> import axios from 'axios' export default { data () { const fileList2CellRender = { name: 'VxeUpload', props: { multiple: true, showButtonText: false, pasteToUpload: true, moreConfig: { maxCount: 1, layout: 'horizontal' }, uploadMethod ({ file }) { const formData = new FormData() formData.append('file', file) return axios.post('/api/pub/upload/single', formData).then((res) => { // { url: ''} return { ...res.data } }) } } } const imgList2CellRender = { name: 'VxeUpload', props: { mode: 'image', multiple: true, showButtonText: false, pasteToUpload: true, moreConfig: { maxCount: 1 }, imageStyle: { width: 40, height: 40 }, uploadMethod ({ file }) { const formData = new FormData() formData.append('file', file) return axios.post('/api/pub/upload/single', formData).then((res) => { // { url: ''} return { ...res.data } }) } } } const gridOptions = { border: true, showOverflow: true, columnConfig: { resizable: true }, columns: [ { type: 'seq', width: 70 }, { field: 'name', title: 'Name', minWidth: 180 }, { field: 'fileList2', title: '上傳附件', width: 300, cellRender: fileList2CellRender }, { field: 'imgList2', title: '上傳圖片', width: 210, cellRender: imgList2CellRender } ], data: [ { id: 10001, name: 'Test1', imgList2: [], fileList2: [{ name: 'fj562.png', url: 'https://vxeui.com/resource/img/fj562.png' }] }, { id: 10002, name: 'Test2', imgList2: [{ name: 'fj562.png', url: 'https://vxeui.com/resource/img/fj562.png' }, { name: 'fj573.jpeg', url: 'https://vxeui.com/resource/img/fj573.jpeg' }], fileList2: [] }, { id: 10003, name: 'Test3', imgList2: [{ name: 'fj577.jpg', url: 'https://vxeui.com/resource/img/fj577.jpg' }], fileList2: [{ name: 'fj562.png', url: 'https://vxeui.com/resource/img/fj562.png' }, { name: 'fj573.jpeg', url: 'https://vxeui.com/resource/img/fj573.jpeg' }, { name: 'fj187.jpg', url: 'https://vxeui.com/resource/img/fj187.jpg' }] } ] } return { gridOptions, fileList2CellRender, imgList2CellRender } } } </script>
查看 Gitee https://gitee.com/x-extends/vxe-table
到此這篇關(guān)于vxe-table 使用 vxe-upload 在表格中實現(xiàn)非常強大的粘貼上傳圖片和附件的文章就介紹到這了,更多相關(guān)vxe-table粘貼上傳圖片和附件內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
element-ui和vue表單(對話框)驗證提示語(殘留)清除操作
這篇文章主要介紹了element-ui和vue表單(對話框)驗證提示語(殘留)清除操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-09-09Vue.js頁面中有多個input搜索框如何實現(xiàn)防抖操作
debounce是lodash工具庫中的一個非常好用的函數(shù)。這篇文章主要介紹了Vue.js頁面中有多個input搜索框如何實現(xiàn)防抖操作,需要的朋友可以參考下2019-11-11vue項目中輪詢狀態(tài)更改方式(鉤子函數(shù))
這篇文章主要介紹了vue項目中輪詢狀態(tài)更改方式(鉤子函數(shù)),具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-10-10