Part1:npm i vant -S安装失败
官网:https://youzan.github.io/vant/#/zh-CN/quickstart
由于依赖环境使用的是cnpm install 所以更换成 cnpm i vant -S 即可!
npm i vant -S:
npm WARN checkPermissions Missing write access to F:\VUE\myproject\node_modules\cssnano\node_modules\autoprefixer
npm ERR! path F:\VUE\myproject\node_modules\csso\node_modules\source-map
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall access
npm ERR! enoent ENOENT: no such file or directory, access 'F:\VUE\myproject\node_modules\csso\node_modules\source-map'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
Part2:局部组件Unknown custom element错误
文档:https://youzan.github.io/vant/#/zh-CN/form
以Vant Form 表单为例,全局引用的时候没问题,局部的时候就报下面错误,这是由于表单里面还有van-field组件,所以需要把van-field也引入
[Vue warn]: Unknown custom element: <van-field> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
import { Form } from 'vant';
Vue.use(Form);
import 'vant/lib/form/style';
import { Field } from 'vant';
Vue.use(Field);
import 'vant/lib/field/style';