Skip to content

Commit ca37fba

Browse files
committed
docs: 添加 vue quick start
1 parent 8046bd9 commit ca37fba

File tree

2 files changed

+56
-3
lines changed

2 files changed

+56
-3
lines changed

packages/s2-vue/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,11 @@ const rawOptions: S2Options = {
336336
### 2. 组件配置
337337

338338
```ts
339+
// App.vue
339340
<script lang="ts">
340341
import type { S2DataConfig, S2Options } from '@antv/s2';
342+
import { Sheet } from '@antv/s2-vue';
341343
import { defineComponent, onMounted, reactive, ref, shallowRef } from 'vue';
342-
import { Sheet } from '../src';
343344

344345
export default defineComponent({
345346
setup() {

s2-site/docs/manual/getting-started.zh.md

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ s2.render()
181181

182182
### `React` 版本
183183

184-
`S2` 提供了开箱即用的 `React` 版本 [表格组件](/zh/examples/gallery#category-表格组件),还有配套丰富的 [分析组件](/zh/examples/gallery#category-Tooltip), 帮助开发者快速满足业务看数分析需求。
184+
`S2` 提供了开箱即用的 `React` 版本 [表格组件](/zh/examples/gallery#category-表格组件,还有配套丰富的 [分析组件](/zh/examples/gallery#category-Tooltip), 帮助开发者快速满足业务看数分析需求。
185185

186186
使用 `React` 版本 `S2`,只有渲染这一步有所不同:
187187

@@ -203,7 +203,59 @@ ReactDOM.render(
203203

204204
```
205205

206-
​📊 查看 demo [React 版本透视表](/zh/examples/react-component/sheet#pivot)
206+
### `Vue` 版本
207+
208+
`S2` 同时也提供了开箱即用的 `Vue` 版本 [表格组件](###), 帮助开发者快速满足业务看数分析需求。
209+
210+
使用 `Vue` 版本 `S2`
211+
212+
#### 表格组件使用
213+
214+
```ts
215+
// App.vue
216+
<script lang="ts">
217+
import type { S2DataConfig, S2Options } from '@antv/s2';
218+
import { Sheet } from '@antv/s2-vue';
219+
import { defineComponent, onMounted, reactive, ref, shallowRef } from 'vue';
220+
221+
export default defineComponent({
222+
setup() {
223+
// dataCfg 数据字段较多,建议使用 shallow, 如果有数据更改直接替换整个对象
224+
const dataCfg = shallowRef(s2DataConfig);
225+
const options: S2Options = reactive(s2Options);
226+
227+
return {
228+
dataCfg,
229+
options,
230+
};
231+
},
232+
233+
components: {
234+
Sheet,
235+
},
236+
});
237+
</script>
238+
239+
<template>
240+
<Sheet :dataCfg="dataCfg" :options="options" />
241+
</template>
242+
243+
<style lang="less">
244+
@import 'ant-design-vue/dist/antd.less';
245+
</style>
246+
```
247+
248+
#### 渲染组件
249+
250+
```ts
251+
import { createApp } from 'vue';
252+
import App from './App.vue';
253+
254+
createApp(App).mount('#app');
255+
256+
```
257+
258+
​📊 查看 demo [Vue 版本透视表](###)
207259

208260
## ⌨️ 本地开发
209261

0 commit comments

Comments
 (0)