0

我正在使用带有 babel-plugin-import 的模块化 antdv,当 import InputSearch 向我抛出标题中描述的错误时。

  • “ant-design-vue”:“^2.2.8”
  • “vue”:“^3.0.0”
// main.js

import { createApp } from "vue";
import App from "./App.vue";
import { ConfigProvider, Button, Form, Input, InputSearch } from "ant-design-vue";

import "./styles/index.less";

const app = createApp(App);

app.use(ConfigProvider);
app.use(Button);
app.use(Form);
app.use(Input);
app.use(InputSearch);

app.mount("#app");

显示的错误:

These dependencies were not found:

* ant-design-vue/es/input-search in ./src/main.js
* ant-design-vue/es/input-search/style in ./src/main.js 
// babel.config.js

module.exports = {
  presets: ["@vue/cli-plugin-babel/preset"],
  plugins: [
    [
      "import",
      { libraryName: "ant-design-vue", libraryDirectory: "es", style: true }
    ] // `style: true` for less
  ]
};

4

1 回答 1

0

解决方案是删除 InputSearch 并且仅在使用 vuejs 时使用 Input 并且它可以工作。

import {
  ConfigProvider,
  Button,
  Form,
  Input,
// InputSearch // <--- remove it
} from "ant-design-vue";
于 2021-10-11T13:20:40.733 回答