vue :src 不显示的解决方案
2024-10-08 16:01:43
一定要将静态资源引入 【 require("@/assets/") 】,绑定到 模型绑定的:src 数据中 动态的数据才能有效
<template>
<div>
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>动态列表</span>
<el-button style="float: right; padding: 3px 0" type="text">操作按钮</el-button>
</div>
<div class="list">
<el-table
ref="multipleTable"
:data="dataPicture"
tooltip-effect="dark"
style="width: 100%"
@selection-change="handleSelectionChange">
<el-table-column
type="selection"
width="55">
</el-table-column>
<el-table-column
label="用户"
width="120">
<template slot-scope="scope">{{ (scope.row.user).username }}</template>
</el-table-column>
<el-table-column
label="内容"
width="220">
<template slot-scope="scope">{{ scope.row.body }}</template>
</el-table-column>
<el-table-column
label="图片"
width="220">
<template slot-scope="scope">
<div v-for="(img, index) in scope.row.imgArr" :key="index">
<img :src="getImgUrl(img.path)" alt="" class="img">
</div>
</template>
</el-table-column>
<el-table-column
label="时间"
width="220">
<template slot-scope="scope">{{ scope.row.date }}</template>
</el-table-column>
<el-table-column
label="操作"
show-overflow-tooltip>
<template slot-scope="scope">
<el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
<el-button type="text" size="small">编辑</el-button>
</template>
</el-table-column>
</el-table>
</div>
</el-card>
</div>
</template>
<script>
export default {
data() {
return {
dataPicture:[],
}
},
methods: {
handleClick(row) {
console.log(row);
},
handleSelectionChange(val) {
// console.log(val);
this.multipleSelection = val;
},
getImgUrl(icon){
return require("@/assets/"+icon);
}
},
async created() {
var res = await this.$http.get('/picture')
this.dataPicture = res.data
// console.log(typeof this.dataPicture[0].user);
},
}
</script>
<style scoped>
.img{
width: 100px;
height: 100px;
}
</style>
最新文章
- IOS 2D游戏开发框架 SpriteKit-->;续(完善角色功能)
- c# TimeSpan
- 关于String StringBuffer StringBuilder
- cocos2dx 锁定30帧设置
- STM32F4_USART配置及细节描述
- [RxJS] Combination operator: combineLatest
- 解决animate动画连续播放bug
- Render和template?
- (删)Java线程同步实现一:synchronzied和wait()/notify()
- 【Android Developers Training】 25. 保存文件
- java面向对象基础(二)
- Filte过滤器
- 6.移动端App安装包的测试用例
- vscode的环境变量code
- hadoop - 基础操作
- Asp.Net Core 2.0 项目实战(5)Memcached踩坑,基于EnyimMemcachedCore整理MemcachedHelper帮助类。
- [原]关于helios自定义面板简述
- c# yield关键字原理详解
- C#编程(五十一)----------链表
- python获取命令行参数 启动文件
热门文章
- leetCode练题——14. Longest Common Prefix
- javascript 变量、常量 、 函数 声明
- 装有Ubuntu的硬盘插入到电脑中无法进入
- hadoop3.1.1高可用集群web端口9870
- ubuntu13.10安装增强功能
- shell脚本添加脚本执行时间和当前运行次数current running time
- NB-IoT的介绍最终版 !看明白了吗?(转自 top-iot)
- 10 JavaScript对象&;类&;for循环
- spring cloud spring boot JPA 克隆对象修改属性后 无法正常的执行save方法进行保存或者更新
- Spring学习(三)