Vant: 使用2.0.0版本的vant,按需引入vant模块时,有些模块可以成功引入,有些会报错是怎么回事?

Created on 28 May 2019  ·  3Comments  ·  Source: youzan/vant

我使用2.0.0版本的vant,按需引入vant模块时,有些模块可以成功引入,有些会报错是怎么回事?
import { Button, Cell, CellGroup, DropdownMenu, DropdownItem, Image, Field, Row, Col, Popup, Icon, Checkbox, CheckboxGroup} from 'vant';

Vue.use(Button).use(Cell) .use(CellGroup) .use(DropdownMenu) .use(DropdownItem) .use(Image) .use(Field) .use(Row) .use(Col) .use(Popup) .use(Icon) .use(Checkbox) .use(CheckboxGroup);

然后报错某些模块不存在:
These dependencies were not found:

  • vant/es/dropdown-item in ./src/vant.js
  • vant/es/dropdown-item/style in ./src/vant.js
  • vant/es/dropdown-menu in ./src/vant.js
  • vant/es/dropdown-menu/style in ./src/vant.js
  • vant/es/image in ./src/vant.js
  • vant/es/image/style in ./src/vant.js
    To install them, you can run: npm install --save vant/es/dropdown-item vant/es/dropdown-item/style vant/es/dropdown-menu vant/es/dropdown-menu/style vant/e
    s/image vant/es/image/style

怎么会这样呢?是不是我少写了什么?

Most helpful comment

看一下node_modules/vant/路径下的package.json文件,vant版本是不是2.0的。不是2.0的话,执行一下npm i vant@beta -S

All 3 comments

看一下node_modules/vant/路径下的package.json文件,vant版本是不是2.0的。不是2.0的话,执行一下npm i vant@beta -S

我使用的vant2.0 beta版本 按需引入组件的时候不会智能提示, 用的编辑器是webstorm 。但是组件实际是可以用,只是不智能提示, 你看下你的组件库是否是2.0 版本以上。楼上的方法是对的

npm i vant@beta -S

大版本升级为啥 npm update 不行呢?

Was this page helpful?
0 / 5 - 0 ratings