This is a quickstart tutorial for using vtk.js with vue.js.
Initialize your project
Install the vue-cli as per the vue-cli docs. Then, create and initialize your project with vue create. For this example, we will be using Vue 3 and npm.
$ vue create my-vtkjs-app > Select Vue 3 defaults
$ cd my-vtkjs-app
Now install vtk.js as a dependency.
$ npm install @kitware/vtk.js
Configure your project
@kitware/vtk.js targets ES6+ output, which means if you are intending to target ES5 browsers, you must tell vue-cli to transpile @kitware/vtk.js. Update your vue.config.js file to look like the following snippet below. Visit the vue-cli documentation for more info.
module.exports = defineConfig({ ... // If you want to transpile all dependencies: transpileDependencies: true,
// If you selectively transpile dependencies: transpileDependencies: ["@kitware/vtk.js"], });
Using vtk.js in your app
To add a minimal vtk.js example to your app, replace src/components/HelloWorld.vue with the following contents.