- 原因:其中vantImage组件中onLoad方法与uniApp冲突,导致项目卡顿无法运行
- 临时解决方法:修改vant源码
源码路径: node_modules/vant/es/image/index.js
将以下方法中的 onLoad -> onImageLoad, onError -> onImageError
methods: {
onImageLoad: function onLoad(event) {
this.loading = false;
this.$emit('load', event);
},
onLazyLoaded: function onLazyLoaded(_ref) {
var el = _ref.el;
if (el === this.$refs.image && this.loading) {
this.onImageLoad();
}
},
genImage: function genImage() {
var h = this.$createElement;
var imgData = {
class: bem('img'),
attrs: {
alt: this.alt
},
style: {
objectFit: this.fit
}
};
if (this.error) {
return;
}
if (this.lazyLoad) {
return h("img", _mergeJSXProps([{
"ref": "image",
"directives": [{
name: "lazy",
value: this.src
}]
}, imgData]));
}
return h("img", _mergeJSXProps2([{
"attrs": {
"src": this.src
},
"on": {
"load": this.onImageLoad,
"error": this.onImageError
}
}, imgData]));
},
onLazyLoadError: function onLazyLoadError(_ref2) {
var el = _ref2.el;
if (el === this.$refs.image && !this.error) {
this.onImageError();
}
},
onImageError: function onError(event) {
this.error = true;
this.loading = false;
this.$emit('error', event);
}
}