首页 > 解决方案 > 为什么标记 loadstart 事件不触发?有替代方案吗?

问题描述

我将 vuejs 与 Element UI 一起使用,我想在开始从 src attr 加载图像时显示加载指示器,在load事件(加载的 img)触发时隐藏加载指示器。

load事件运行良好,但从loadstart不触发。

这是片段:

<div v-loading="imgLoading">
  <img
    :src="imgOfSelectedColor"
    @loadstart="showImgLoading"
    @load="hideImgLoading"
    @error="hideImgLoading"
    @abort="hideImgLoading"
  >
</div>
export default {
  data() {
    return {
      imgLoading: false
    };
  },
  methods: {
    showImgLoading() {
      this.imgLoading = true;
    },
    hideImgLoading() {
      this.imgLoading = false;
    }
  }
}

标签: javascripthtmlvue.jsvuejs2

解决方案


推荐阅读