Skip to content

Commit 1f154cf

Browse files
docs: add vue 3 example
1 parent e8ae651 commit 1f154cf

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

docs/content/docs/frameworks.mdx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export { Simulation };
6969
When using Next.js make sure to include `'use client';` at the top of the file
7070
</Callout>
7171

72-
## Vue
72+
## Vue 2
7373

7474
```vue title="Simulation.vue"
7575
<template>
@@ -94,6 +94,31 @@ export { Simulation };
9494
</script>
9595
```
9696

97+
## Vue 3
98+
99+
```vue
100+
<template>
101+
<div ref="container" style="width: 100vw; height: 100vh"></div>
102+
</template>
103+
104+
<script setup>
105+
import { onMounted, onBeforeUnmount, ref } from 'vue';
106+
import WebGLFluidEnhanced from 'webgl-fluid-enhanced';
107+
108+
const container = ref(null);
109+
let simulation = null;
110+
111+
onMounted(() => {
112+
simulation = new WebGLFluidEnhanced(container.value);
113+
simulation.start();
114+
});
115+
116+
onBeforeUnmount(() => {
117+
if (simulation) simulation.stop();
118+
});
119+
</script>
120+
```
121+
97122
## Angular
98123

99124
```ts title="simulation.component.ts"

0 commit comments

Comments
 (0)