Skip to content

Commit

Permalink
docs: add auto import docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kagol committed Mar 8, 2024
1 parent 753d8c7 commit feb509d
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 4 deletions.
42 changes: 40 additions & 2 deletions examples/sites/demos/pc/webdoc/import-components-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,47 @@

## Introduction Components

`TinyVue`Multiple component introduction, single component introduction, and complete introduction are supported.
`TinyVue` supports automatic import, multiple component import, single component import, and complete import.

### Multi-component introduction (recommended)
### Auto import (recommended)

First, you need to install the plugin `@opentiny/unplugin-tiny-vue`.

```bash
npm i @opentiny/unplugin-tiny-vue -D
```

Then, insert the following code into your project's `Vite` or `Webpack` configuration file.

Vite

```ts
// vite.config.ts

import autoImportPlugin from '@opentiny/unplugin-tiny-vue'

export default {
plugins: [autoImportPlugin()]
}
```

Webpack

```js
// webpack.config.js

const autoImportPlugin = require('@opentiny/unplugin-tiny-vue')

module.exports = {
plugins: [autoImportPlugin()]
}
```

This way, you can directly use TinyVue components in your project. These components are automatically imported on demand, without the need for manual import, and you don't have to worry about the project size becoming too large.

For more information about automatic on-demand imports, please refer to [unplugin-vue-components](https://github.com/antfu/unplugin-vue-components) and [unplugin-auto-import](https://github.com/antfu/unplugin-auto-import).

### Multi-component introduction

Multi-component reference is from the dependency package.`@opentiny/vue`Multiple components are referenced in. The following is an example (in the following figure)`Button`and`Alert`Component as an example):

Expand Down
42 changes: 40 additions & 2 deletions examples/sites/demos/pc/webdoc/import-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,47 @@

## 引入组件

`TinyVue` 支持多组件引入、单组件引入以及完整引入三种方式
`TinyVue` 支持自动导入、多组件引入、单组件引入以及完整引入四种方式

### 多组件引入(推荐)
### 自动导入(推荐)

首先你需要安装 `@opentiny/unplugin-tiny-vue` 这款插件。

```bash
npm i @opentiny/unplugin-tiny-vue -D
```

然后把以下代码插入到你项目的 `Vite``Webpack` 配置文件中。

Vite

```ts
// vite.config.ts

import autoImportPlugin from '@opentiny/unplugin-tiny-vue'

export default {
plugins: [autoImportPlugin()]
}
```

Webpack

```js
// webpack.config.js

const autoImportPlugin = require('@opentiny/unplugin-tiny-vue')

module.exports = {
plugins: [autoImportPlugin()]
}
```

这样你就能直接在项目中使用 TinyVue 的组件,这些组件都是自动按需导入的,无需手动导入,且不用担心项目体积变得太大。

想了解更多自动按需导入的信息,请参考:[unplugin-vue-components](https://github.com/antfu/unplugin-vue-components)[unplugin-auto-import](https://github.com/antfu/unplugin-auto-import)

### 多组件引入

多组件引用即从依赖包 `@opentiny/vue` 中引用多个组件,参考示例如下(以 `Button``Alert` 组件为例):

Expand Down

0 comments on commit feb509d

Please sign in to comment.