[youzan/vant]vue3+vite+ts项目,引入vant4报错:Cannot read properties of null (reading 'proxy')

2023-12-18 562 views
7
重现链接

因为没有github仓库,因此使用百度云传递本地代码 https://pan.baidu.com/s/1ep18nTk3wz-hZGy2fMetnw?pwd=9utp

Vant 版本

4.0.11

描述一下你遇到的问题。

引入vant4组件,启动项目之后,页面报错

Cannot read properties of null (reading 'proxy')
    at useRoute (use-route.mjs:22:33)
    at setup (Cell.mjs:35:19)
    at callWithErrorHandling (runtime-core.esm-bundler.js:155:22)
    at setupStatefulComponent (runtime-core.esm-bundler.js:7165:29)
    at setupComponent (runtime-core.esm-bundler.js:7120:11)
    at mountComponent (runtime-core.esm-bundler.js:5473:13)
    at processComponent (runtime-core.esm-bundler.js:5448:17)
    at patch (runtime-core.esm-bundler.js:5038:21)
    at mountChildren (runtime-core.esm-bundler.js:5234:13)
    at processFragment (runtime-core.esm-bundler.js:5407:13)
重现步骤

npm start 启动后修改访问地址为:http://127.0.0.1:19168/#/WEB_APP/frontendKnowledge/main

!!!补充:在 frontendKnowledge/main/index.tsx文件中引入并使用vant的button或者cell组件

打开控制台即可看到报错

设备/浏览器

chrome,edge

回答

3

我这运行正常哦 你是不是签入到App壳子里,运行环境版本过低不支持 proxy

image

7

我这运行正常哦 你是不是签入到App壳子里,运行环境版本过低不支持 proxy

image

请问您是否使用了vant的组件呢,我是使用vant的组件不展示,并且报错。我开始写的问题不清楚,我补充了一下描述:

主要是在页面中使用了vant的button或者cell组件,运行就会报错。

我是直接在chrome和edge浏览器里面直接运行的页面,没有在APP环境,node版本用的18.14.2

7

正常哈,不过不知道是不是你配置问题,组件的样式没加载到,我是引入了一下。 image

image

9

重装了一下依赖,可以了T_T,感谢指教