Skip to content

Commit 23c35f5

Browse files
author
fanyang
committed
fix: 修复官网demo报错
1 parent 716dce1 commit 23c35f5

File tree

3 files changed

+47
-90
lines changed

3 files changed

+47
-90
lines changed

sites/docs/docs/tutorial/getting-started.en-US.md

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -99,51 +99,8 @@ lf.render(data)
9999

100100
LogicFlow itself is packaged as pure JS with UMD, making it compatible with both Vue and React frameworks. One key point to note is that when initializing a LogicFlow instance, the container parameter must refer to an existing DOM node to avoid errors.
101101

102-
```jsx
103-
import LogicFlow from "@logicflow/core";
104-
import "@logicflow/core/dist/index.css";
105-
import { useEffect, useRef } from "react";
106-
107-
export default function App() {
108-
const refContainer = useRef();
109-
const data = {
110-
// Nodes
111-
nodes: [
112-
{
113-
id: '21',
114-
type: 'rect',
115-
x: 300,
116-
y: 100,
117-
text: 'rect node',
118-
},
119-
{
120-
id: '50',
121-
type: 'circle',
122-
x: 500,
123-
y: 100,
124-
text: 'circle node',
125-
},
126-
],
127-
// Edges
128-
edges: [
129-
{
130-
type: 'polyline',
131-
sourceNodeId: '50',
132-
targetNodeId: '21',
133-
},
134-
],
135-
}
136-
useEffect(() => {
137-
const lf = new LogicFlow({
138-
container: refContainer.current,
139-
grid: true,
140-
height: 200
141-
});
142-
lf.render(data);
143-
}, []);
144-
return <div className="App" ref={refContainer}></div>;
145-
}
146-
```
102+
<code id="use-in-react" src="../../src/tutorial/getting-started/use-in-react"></code>
103+
147104
### 3. Usage in Vue Framework
148105

149106
```vue

sites/docs/docs/tutorial/getting-started.md

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -113,51 +113,7 @@ lf.render(data)
113113

114114
LogicFlow 本身是以 umd 打包为纯 JS 的包,所以不论是 vue 还是 react 中都可以使用。这里需要注意一个点,那就是初始化 LogicFlow 实例的时候,传入的参数 container,必须要 dom 上存在这个节点,不然会报错请检查 container 参数是否有效。
115115

116-
```jsx
117-
import LogicFlow from "@logicflow/core";
118-
import "@logicflow/core/dist/index.css";
119-
import { useEffect, useRef } from "react";
120-
121-
export default function App() {
122-
const refContainer = useRef();
123-
const data = {
124-
// 节点
125-
nodes: [
126-
{
127-
id: '21',
128-
type: 'rect',
129-
x: 300,
130-
y: 100,
131-
text: 'rect node',
132-
},
133-
{
134-
id: '50',
135-
type: 'circle',
136-
x: 500,
137-
y: 100,
138-
text: 'circle node',
139-
},
140-
],
141-
//
142-
edges: [
143-
{
144-
type: 'polyline',
145-
sourceNodeId: '50',
146-
targetNodeId: '21',
147-
},
148-
],
149-
}
150-
useEffect(() => {
151-
const lf = new LogicFlow({
152-
container: refContainer.current,
153-
grid: true,
154-
height: 200
155-
});
156-
lf.render(data);
157-
}, []);
158-
return <div className="App" ref={refContainer}></div>;
159-
}
160-
```
116+
<code id="use-in-react" src="../../src/tutorial/getting-started/use-in-react"></code>
161117

162118
### 3. Vue 框架中使用
163119

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import LogicFlow from '@logicflow/core';
2+
import '@logicflow/core/dist/index.css';
3+
import { useEffect, useRef } from 'react';
4+
5+
export default function App() {
6+
const refContainer = useRef(null);
7+
const data = {
8+
// 节点
9+
nodes: [
10+
{
11+
id: '21',
12+
type: 'rect',
13+
x: 300,
14+
y: 100,
15+
text: 'rect node',
16+
},
17+
{
18+
id: '50',
19+
type: 'circle',
20+
x: 500,
21+
y: 100,
22+
text: 'circle node',
23+
},
24+
],
25+
// 边
26+
edges: [
27+
{
28+
type: 'polyline',
29+
sourceNodeId: '50',
30+
targetNodeId: '21',
31+
},
32+
],
33+
};
34+
useEffect(() => {
35+
const lf = new LogicFlow({
36+
container: refContainer.current,
37+
grid: true,
38+
height: 200,
39+
});
40+
lf.render(data);
41+
}, []);
42+
43+
return <div className="App" ref={refContainer}></div>;
44+
}

0 commit comments

Comments
 (0)