Blame view

Yi.Vben5.Vue3/docs/src/en/guide/essentials/external-module.md 1.27 KB
515fceeb   “wangming”   框架初始化
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
  # External Modules
  
  In addition to the external modules that are included by default in the project, sometimes we need to import other external modules. Let's take [ant-design-vue](https://antdv.com/components/overview) as an example:
  
  ## Installing Dependencies
  
  ::: tip Install dependencies into a specific package
  
  - Since the project uses [pnpm](https://pnpm.io/) as the package management tool, we need to use the `pnpm` command to install dependencies.
  - As the project is managed using a Monorepo module, we need to install dependencies under a specific package. Please make sure you have entered the specific package directory before installing dependencies.
  
  :::
  
  ```bash
  # cd /path/to/your/package
  pnpm add ant-design-vue
  ```
  
  ## Usage
  
  ### Global Import
  
  ```ts
  import { createApp } from 'vue';
  import Antd from 'ant-design-vue';
  import App from './App';
  import 'ant-design-vue/dist/reset.css';
  
  const app = createApp(App);
  
  app.use(Antd).mount('#app');
  ```
  
  #### Usage
  
  ```vue
  <template>
    <a-button>text</a-button>
  </template>
  ```
  
  ### Partial Import
  
  ```vue
  <script setup lang="ts">
  import { Button } from 'ant-design-vue';
  </script>
  
  <template>
    <Button>text</Button>
  </template>
  ```
  
  ::: warning Note
  
  - If the component depends on styles, you also need to import the style file.
  
  :::