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'] } } ] } }