使用npm安装vant后,如果直接按照Vant Weapp的官方文档来引入toast,会报错路径错误
import Toast from 'path/to/@vant/weapp/dist/toast/toast';
// error:
thirdScriptError
module "pages/admin/bookList/path/to/@vant/weapp/dist/toast/toast" is not defined
Error: module "pages/admin/bookList/path/to/@vant/weapp/dist/toast/toast" is not defined
因为官方给出的路径是有问题的,正确的写法是
import Toast from '@vant/weapp/toast/toast'
然后,按照文档来做就OK了。
https://youzan.github.io/vant-weapp/#/toast
Vant Weapp的其它组件路径问题,也差不多一样解决。