vue:为什么 后台获取的图片首次渲染出现空白,再次手动刷新后才会出现?

场景: ios 微信
后台获取的图片为http开头的超链接
首次在ios(微信)中打开图片渲染是空白的 数据有获取到
再次刷新后图片才会显示正常
经过测试在android没有出现上述问题

html

<div class="bugImg" v-if="bugDetail">
  <img
    v-for="(imgItem,index) in bugDetail.disposefileList"
    :key="imgItem.index"
    :src="imgItem"
    alt
    @click="imagePreview(index)"
   >
</div>

js

export default {
  name: "BugDetail",
  data() {
    return {
      bugId: "",
      bugDetail: {},
    };
  },
  created() {
    this.bugId = this.$route.query.bugId;
  },
  mounted() {
    this.getBugDetail();
  },
  methods: {
    getBugDetail() {
      let data = {
        id: this.bugId
      };
      API.getBugById(data)
        .then(res => {
          if (res.errCode == 0) {
            this.bugDetail = res.data;
          } else {
          }
        })
        .catch(error => {});
    },
  },
  components: {
  }
};
阅读 4.3k
2 个回答
✓ 已被采纳新手上路,请多包涵

查到原因了 把后台返回的链接由http换成https解决了这个问题 应该是微信安全策略导致的 具体原因还不清楚 如果有大神了解 麻烦解释下 目前来看跟我上面贴的代码关系不大

试下加个:v-if="imgItem"

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题