Table表格中使用el-image


1. 按需引入組件

import {Image} from 'element-ui'
Vue.use(Image)

2. 在 Table表格 中使用 el-image

<el-table-column
        prop="photo"
        label="頭像">
    <template slot-scope="scope">
        <el-image
            style="width: 100px; height: 100px"
            :src="scope.row.photo.url"
            :fit="scope.row.photo.fit"
            :preview-src-list="scope.row.photo.preview">
        </el-image>
    </template>
</el-table-column>

注意其中點擊顯示大圖的 preview 的數據結構應該是一個數組

data () {
    return {
        tableData: [
            {
                photo:{
                    url:''
                    fit: 'fill'
                    preview: ['https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg']
                }   
            }
        ]
    }
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM