Skip to content

Commit ddb3c15

Browse files
committed
feat: add on-demand manual import section to getting started guide
1 parent 9f77b5f commit ddb3c15

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

docs/en/guide/getting-started.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,40 @@ app.mount('#app')
4444
</template>
4545
```
4646

47+
### On-demand Manual Import
48+
49+
You can manually import the components you need (components consist of logic files and style files):
50+
51+
```ts
52+
// main.ts
53+
import { StSayHello } from 'starter-lib-vue3'
54+
import { createApp } from 'vue'
55+
import App from './App.vue'
56+
57+
import 'starter-lib-vue3/dist/es/say-hello/SayHello.css'
58+
59+
const app = createApp(App)
60+
61+
app.use(StSayHello).mount('#app')
62+
```
63+
64+
Or import and use in SFC:
65+
66+
```vue
67+
<script>
68+
import { StSayHello } from 'starter-lib-vue3'
69+
import 'starter-lib-vue3/dist/es/say-hello/SayHello.css'
70+
71+
export default {
72+
components: { StSayHello },
73+
}
74+
</script>
75+
76+
<template>
77+
<StSayHello />
78+
</template>
79+
```
80+
4781
## Browser Direct Import
4882

4983
You can use the global variable `StarterLibVue3` by importing directly through the browser's HTML `script` tag.

docs/zh/guide/getting-started.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,40 @@ app.mount('#app')
4444
</template>
4545
```
4646

47+
### 按需手动导入
48+
49+
你可已手动导入你需要的组件(组件由逻辑文件和样式文件组成):
50+
51+
```ts
52+
// main.ts
53+
import { StSayHello } from 'starter-lib-vue3'
54+
import { createApp } from 'vue'
55+
import App from './App.vue'
56+
57+
import 'starter-lib-vue3/dist/es/say-hello/SayHello.css'
58+
59+
const app = createApp(App)
60+
61+
app.use(StSayHello).mount('#app')
62+
```
63+
64+
或者在 SFC 中导入使用:
65+
66+
```vue
67+
<script>
68+
import { StSayHello } from 'starter-lib-vue3'
69+
import 'starter-lib-vue3/dist/es/say-hello/SayHello.css'
70+
71+
export default {
72+
components: { StSayHello },
73+
}
74+
</script>
75+
76+
<template>
77+
<StSayHello />
78+
</template>
79+
```
80+
4781
## 浏览器直接引入
4882

4983
直接通过浏览器的 HTML `script` 标签导入就可以使用全局变量 `StarterLibVue3` 了。

0 commit comments

Comments
 (0)