vxe-table?使用?vxe-upload?在表格中實(shí)現(xiàn)非常強(qiáng)大的粘貼上傳圖片和附件功能
看看 vxe-table 渲染器強(qiáng)大到什么地步;在開發(fā)需求中,經(jīng)常會(huì)在表格列表中放入圖片展示,例如頭像、視頻圖片,附件列表等,但需要對表格批量操作是,會(huì)比較繁瑣,那么有沒有方便操作一點(diǎn)的放呢,肯定是有的;
配合 vxe-upload 上傳;比如復(fù)制或者截圖一張圖片,通過粘貼方式快速粘貼到單元格中,能支持單張、多張、查看、預(yù)覽。上傳精進(jìn)度等。
官網(wǎng):https://vxetable.cn

渲染 vxe-upload,實(shí)現(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 在表格中實(shí)現(xiàn)非常強(qiáng)大的粘貼上傳圖片和附件的文章就介紹到這了,更多相關(guān)vxe-table粘貼上傳圖片和附件內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
element-ui和vue表單(對話框)驗(yàn)證提示語(殘留)清除操作
這篇文章主要介紹了element-ui和vue表單(對話框)驗(yàn)證提示語(殘留)清除操作,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-09-09
vue3項(xiàng)目引入pinia報(bào)錯(cuò)的簡單解決
這篇文章主要介紹了vue3項(xiàng)目引入pinia報(bào)錯(cuò)的簡單解決,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-10-10
Vue.js頁面中有多個(gè)input搜索框如何實(shí)現(xiàn)防抖操作
debounce是lodash工具庫中的一個(gè)非常好用的函數(shù)。這篇文章主要介紹了Vue.js頁面中有多個(gè)input搜索框如何實(shí)現(xiàn)防抖操作,需要的朋友可以參考下2019-11-11
vue項(xiàng)目中輪詢狀態(tài)更改方式(鉤子函數(shù))
這篇文章主要介紹了vue項(xiàng)目中輪詢狀態(tài)更改方式(鉤子函數(shù)),具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-10-10
vue3限制table表格選項(xiàng)個(gè)數(shù)的解決方法
這篇文章主要為大家詳細(xì)介紹了vue3限制table表格選項(xiàng)個(gè)數(shù)的解決方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-04-04

