在前两期分享中,我们已经讲过如何在uniapp中引用vant。在引用vant后,在使用Grid宫格组件时,会发现不兼容及console报错的情况。如图:
问题是说编译之后的vant组件库中的/wxcomponents/vant/grid-item/index.js文件渲染找不到indexOf()方法
Error in mounted hook: "TypeError: Cannot read properties of undefined (reading 'indexOf')"
以下是我的解决方案。简单粗暴.直接把index.js中43行删除或者注释即可。如果大家的更好的意见可以分享一下。
index: children.indexOf(this), //删除或者注释该行