安装
一般都是安装的版本问题:
先去除已安装的vant:npm uninstall vant
- vue2全局安装Vant:npm i vant@latest-v2 -S
- vue3全局安装Vant:npm i vant -S
使用vue2安装vant常见错误说明
如果直接使用npm i vant -S安装了vant,则报版本冲突不允许安装,如果强制使用 npm i -S --legacy-peerdeps 或者使用 npm i vant -S --force 强制性不管版本安装了vant,虽然可以安装,但是运行时会出现如下错误
ERROR in ./node_modules/vant/es/watermark/Watermark.mjs 55:46-58
export 'createVNode' (imported as '_createVNode') was not found in 'vue' (possible exports: EffectScope, computed, customRef, default, defineAsyncComponent, defineComponent, del, effectSc
ope, getCurrentInstance, getCurrentScope, h, inject, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, mergeDefaults, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBe
foreUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, provide, proxyRefs, reactive, readonly
, ref, set, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useListeners, useSlots, version, watch, watchEffect, watchPostEffect, watchSyncEffect)
@ ./node_modules/vant/es/watermark/index.mjs 2:0-41 3:30-40 5:0-49 6:0-63
@ ./node_modules/vant/es/index.mjs 101:0-50 104:1048-1057 214:0-38 214:0-38
@ ./src/main.js 4:0-24 8:8-12
- 报错信息提示vant版本过高,vue2的版本无法解析。说明你是在vue2安装vant,需要卸载vant,然后安装vue2版本的vant。