我正在使用带有 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
]
};