试了很久,这个可能是el-image的bug吧,以后需要仔细看看源码怎么实现的。 目前发现有两个解决办法,第一个就是在“:src” 里添加默认图片地址,避免渲染DOM的时候找不到地址导致报错;第二种就是本来我只想要使用他的大图预览功能,我想是不是可以设置成img加载图片,只需要找预览的功能,后来发现Image这块大图预览是个组...
使用el-image显示图片加载失败 代码: <el-imagestyle="width: 100%; height:50px; margin:4px 5px 2px 5px;"src="../assets/logo1.png"/> 效果: 解决:src用里面加个require 代码: <el-imagestyle="width: 100%; height:50px; margin:4px 5px 2px 5px;":src="require('../assets/logo1.png'...
1. 当我们请求本地的图片文件时,在路径前面加上require(),可以解决 <el-image class="headPortrait" :src="require(`../../xxx/xxx/${item.img}`)"fit="contain"></el-image> 2. 当我们本地可以显示,但是服务器上加载失败时,这是因为当你在元素里面绑定:src时,Vue将绑定属性的路径作为字符串输出了。
1、使用绝对路径 (不推荐) <el-image :src="'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg'"></el-image> 1. 2、使用import(推荐) <template> <el-image :src="imgUrl"> </el-image> </template> import jpg from '@/assets/images/icon/file/jpg.png' export...
Element UI - el-image 图片初始化加载爬坑 背景原因:el-image 一旦初始化加载失败的话,后期更新是不会出图片的。 解决方案:要么一开始在标签 el-image 里添加“:lazy='true'”,要么在“:src”里添加默认图片地址,避免渲染DOM的时候找不到地址导致报错。
修改HelloWorld.vue(增加使用el-image及其他组件), 跑起来后, el-image对应的图片显示加载失败, 但如果换成绝对地址就能正确加载, 不知道什么原因! 问题出现的环境背景及自己尝试过哪些方法 相关代码 // 请把代码文本粘贴到下方(请勿用图片代替代码)main.js import Vue from 'vue' import ElementUI from 'element...
页面出来了,但图片的懒加载功能却没出来,没有实现官网给出的效果。 代码如下 <template>这是gourmet world页面11111<el-imagev-for="url in urls":key="url":src="url"lazy></el-image></template>export default { name: "GourmetWorld", data() { return { urls: [ "https://fuss10.eleme...
1 /* elementUI的图片组件样式 */ 2 .el-image-viewer__btn,.el-step__icon-inner { 3 -webkit-user-select:none; 4 -moz-user-select:none; 5 -ms-user-select:none 6 } 7 .el-image__error,.el-timeline-item__dot { 8 display:-webkit-box; 9 display:-ms-flexbox 10 } 11 .el-image...
<el-image src="" :error="" :error-attrs="{alt: '加载失败'}" :error-class="error-image"></el-image> ``` 通过设置不同的加载失败处理方式,可以提升用户体验,展示友好的提示信息或图片。 3. 按需加载 除了懒加载外,Image控件还支持按需加载,可以根据特定条件加载图片资源。通过设置lazy-on-demand属性...