# Using Wijmo with Nuxt.js

## Content

<span lang="EN-US" style="mso-ascii-font-family:Aptos;
mso-fareast-font-family:Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:
Aptos;color:black;mso-themecolor:text1">Nuxt is a powerful framework built on top of </span>**<span lang="EN-US" style="mso-ascii-font-family:Aptos;
mso-fareast-font-family:Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:
Aptos;color:black;mso-themecolor:text1">Vue.js</span>**<span lang="EN-US" style="mso-ascii-font-family:Aptos;
mso-fareast-font-family:Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:
Aptos;color:black;mso-themecolor:text1">, designed to simplify the development of </span>**<span lang="EN-US" style="mso-ascii-font-family:Aptos;
mso-fareast-font-family:Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:
Aptos;color:black;mso-themecolor:text1">universal (server-side rendered), static, and single-page applications</span>**<span lang="EN-US" style="mso-ascii-font-family:Aptos;
mso-fareast-font-family:Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:
Aptos;color:black;mso-themecolor:text1">. It provides a structured and opinionated approach to building Vue applications while enhancing performance, developer experience etc.</span>
<span lang="EN-US" style="mso-ascii-font-family:Aptos;
mso-fareast-font-family:Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:
Aptos;color:black;mso-themecolor:text1">Wijmo Components for </span><span style="mso-comment-continuation:2">Vue </span><span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;
mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos;color:black;mso-themecolor:
text1">allow you to use Wijmo controls in a Nuxt.js project. </span><span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;
mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos">A Wijmo Vue component serves as a wrapper for the Wijmo control, automatically creating the control instance behind the scenes. It provides access to the control via the </span><span lang="EN-US" style="font-family:Consolas;mso-fareast-font-family:Consolas;
mso-bidi-font-family:Consolas">ref</span><span lang="EN-US" style="mso-ascii-font-family:
Aptos;mso-fareast-font-family:Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:
Aptos"> property and enables declarative binding to its properties and events.</span>

> type=note
> **<span lang="EN-US" style="mso-ascii-font-family:Aptos;
> mso-fareast-font-family:Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:
> Aptos">Note:</span>** <span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;
> mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos">By default, Nuxt.js applications use Universal mode, which integrates both server-side rendering (SSR) and client-side rendering. However, Wijmo supports the client-side rendering only. Hence, to ensure proper functionality when incorporating Wijmo into a Nuxt.js application, you must disable the server-side rendering by setting the ssr property to false.</span>
>
> ```auto
> export default defineNuxtConfig({ ssr: false })
> ```

<span lang="EN-US" style="mso-ascii-font-family:Aptos;
mso-fareast-font-family:Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:
Aptos">Apart from this setting, you can integrate Wijmo in your Nuxt.js application as you do it in a Vue application. For information on how to integrate Wijmo in your Nuxt/Vue application, see Vue Quick Start.</span>
<span lang="EN-US" style="mso-ascii-font-family:
Aptos;mso-fareast-font-family:Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:
Aptos;color:black;mso-themecolor:text1">Note that you must use the Nuxt CLI to create a Nuxt application, just like you create a Vue application using Vue CLI. For more information on creating Nuxt application, see </span>[<span style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;mso-hansi-font-family:
Aptos;mso-bidi-font-family:Aptos">Getting Started with Nuxt</span>](https://nuxt.com/docs/getting-started/installation)<span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;
mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos;color:black;mso-themecolor:
text1">.</span>

## <span lang="EN-US">Nuxt.js Components</span>

<span lang="EN-US" style="mso-ascii-font-family:Aptos;
mso-fareast-font-family:Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:
Aptos;color:black;mso-themecolor:text1">Wijmo Vue components are available as separate npm packages. npm package for each component is named after its core library with "vue2" included in the package name. </span><span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;
mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos;color:#172B4D">F</span><span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;
mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos">or exam</span><span style="color:#172B4D">p</span>le, "wijmo.vue2.grid" package represents components for controls from the core "wijmo.grid" package. You<span style="color:black;mso-themecolor:text1"> can install the components individually or all of them at once with "wijmo.vue2.all."</span>

```auto
npm install @mescius/wijmo.vue2.all
```

<span lang="EN-US" style="mso-ascii-font-family:Aptos;
mso-fareast-font-family:Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:
Aptos">For more information on Wijmo npm packages, refer to the topic </span>**[<span style="mso-ascii-font-family:
Aptos;mso-fareast-font-family:Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:
Aptos">Reference Wijmo Packages</span>](/wijmo/docs/GettingStarted/Referencing-Wijmo-NPM)*<span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;mso-hansi-font-family:
Aptos;mso-bidi-font-family:Aptos">.</span>***
<span lang="EN-US" style="mso-ascii-font-family:Aptos;
mso-fareast-font-family:Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:
Aptos">In the Nuxt.JS project, the Wijmo components and directives can be directly imported from the wijmo.vue2 packages and can be used in the component </span><span style="color:black;mso-themecolor:text1">by using </span>**<span style="color:black;mso-themecolor:text1">Custom component-level registration</span>** <span style="color:black;mso-themecolor:text1">methods only. </span>Refer to the **Vue 3 Components** topic, for details on these methods.

> type=note
> **<span style="mso-ascii-font-family:Aptos;
> mso-fareast-font-family:Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:
> Aptos;color:black;mso-themecolor:text1" lang="EN-US">Note</span>*<span style="mso-ascii-font-family:Aptos;
> mso-fareast-font-family:Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:
> Aptos;color:black;mso-themecolor:text1" lang="EN-US">:</span>*** <span style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;
> mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos;color:black;mso-themecolor:
> text1" lang="EN-US">Wijmo</span><span style="font-family:Arial,sans-serif;
> mso-fareast-font-family:Arial;color:black;mso-themecolor:text1" lang="EN-US"> </span>*<span style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;
> mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos;color:black;mso-themecolor:
> text1" lang="EN-US">components</span>*<span style="mso-ascii-font-family:Aptos;
> mso-fareast-font-family:Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:
> Aptos;color:black;mso-themecolor:text1" lang="EN-US"> are intended for a usage in Nuxt.js app as component. </span>

<span lang="EN-US" style="mso-ascii-font-family:Aptos;
mso-fareast-font-family:Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:
Aptos;color:black;mso-themecolor:text1">If you want to create a Wijmo control in code, you should use a Wijmo</span><span lang="EN-US" style="font-family:Arial,sans-serif;
mso-fareast-font-family:Arial;color:black;mso-themecolor:text1"> </span>*<span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;
mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos;color:black;mso-themecolor:
text1">control</span>* <span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;
mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos;color:black;mso-themecolor:
text1">from a core module for this purpose, instead of a component. A core module has the same name as a corresponding Vue interop module, but without the "vue" word in the name. For example, this code creates a FlexGrid control in the code:</span>

```auto
import { FlexGrid } from '@mescius/wijmo.grid'; 
onMounted(() => {  
grid = new FlexGrid("#host_element");})
```

### <span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;mso-hansi-font-family:

Aptos;mso-bidi-font-family:Aptos">Adding Wijmo CSS

<span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:
Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos;color:black;
mso-themecolor:text1">Wijmo ships </span>**<span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:
Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos;color:black;
mso-themecolor:text1">@mescius/wijmo.styles</span>**<span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:
Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos;color:black;
mso-themecolor:text1"> npm package which contains the following two files:</span>

* <span lang="EN-US" style="mso-ascii-font-family:
    Aptos;mso-fareast-font-family:Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:
    Aptos;color:black;mso-themecolor:text1">Wijmo.css - includes styles for all controls</span>
* <span lang="EN-US" style="mso-ascii-font-family:
    Aptos;mso-fareast-font-family:Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:
    Aptos;color:black;mso-themecolor:text1">wijmo-core.css - truncated version of wijmo.css. It excludes styles for Enterprise controls.</span>

<span lang="EN-US" style="mso-ascii-font-family:Aptos;
mso-fareast-font-family:Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:
Aptos">You can load the styles in your component that uses Wijmo controls, using this ESM import statement.</span>

```auto
import '@mescius/wijmo.styles/wijmo.css';  
```

### <span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;

mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos">Nuxt.js Markup Syntax

<span lang="EN-US" style="mso-ascii-font-family:Aptos;
mso-fareast-font-family:Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:
Aptos">Wijmo Vue components use </span>[<span style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;mso-hansi-font-family:
Aptos;mso-bidi-font-family:Aptos">Vue3 naming conventions</span>](https://vuejs.org/guide/components/registration.html#component-name-casing)<span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;
mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos"> in template markup. It supports </span>**<span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;
mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos">low-case-dash</span>**<span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;
mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos"> and </span>**<span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;
mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos">camelCase</span>** <span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;
mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos">syntax to specify the component, its properties, and events as follows: </span><span style="mso-spacerun:yes"> </span>

```auto
<wj-input-number :value-changed="ctrlValueChanged"> //low-dash-case
<WjInputNumber :valueChanged= "ctrlValueChanged">  // camelCase  
```

### <span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;mso-hansi-font-family:

Aptos;mso-bidi-font-family:Aptos">DataFlow with attributes

* <span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;
    mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos;color:black;mso-themecolor:
    text1">In case of one-way binding, prepend the names with the </span>**<span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;
    mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos;color:black;mso-themecolor:
    text1">v-bind:</span>**<span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;
    mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos;color:black;mso-themecolor:
    text1"> directive (or its </span>**<span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;
    mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos;color:black;mso-themecolor:
    text1">':'</span>**<span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;
    mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos;color:black;mso-themecolor:
    text1"> shorthand), except while binding a string type property to a string constant. One-way binding is used to set the property’s value or event handler.</span>
* <span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;
    mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos;color:black;mso-themecolor:
    text1">For the two-way binding between form inputs and component data, use the v-model directive. When you use v-model, Vue automatically handles updating the data property and the input element's value.</span>

```auto
<script setup>
import { ref } from 'vue'
import { WjInputNumber } from '@mescius/wijmo.vue2.input';
const count = ref(3)  // variables </script>
<wj-input-number v-model:value="count"  //two way binding
    format="n2" //binding to a string constant
    :isReadOnly="true">//binding to Boolean 
</wj-input-number>  
```

#### <span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;mso-hansi-font-family:

Aptos;mso-bidi-font-family:Aptos">Event handlers

<span lang="EN-US" style="mso-ascii-font-family:Aptos;
mso-fareast-font-family:Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:
Aptos;color:black;mso-themecolor:text1">Wijmo event handlers are defined as functions with two parameters: sender and event argument. </span><span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;
mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos">While binding to a component event, you must specify the name of a function with </span><span style="mso-comment-continuation:2">this signature.</span>

```auto
<script setup>
import { ref } from 'vue'
import { WjInputNumber } from '@mescius/wijmo.vue2.input';
const count = ref(3)  // variables
//event-handlers
function valueChanged(s,e){
    console.log("Control value changed!"+s.value);
}</script>
<template>
<wj-input-number v-model:value="count" :valueChanged="valueChanged"></wj-input-number>
</template> 
```

#### <span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;mso-hansi-font-family:

Aptos;mso-bidi-font-family:Aptos">The "initialized" Event

<span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:
Aptos;mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos">All Wijmo Vue components have an </span><span lang="EN-US" style="font-family:Consolas;
mso-fareast-font-family:Consolas;mso-bidi-font-family:Consolas">initialized</span><span lang="EN-US" style="mso-ascii-font-family:Aptos;mso-fareast-font-family:Aptos;
mso-hansi-font-family:Aptos;mso-bidi-font-family:Aptos"> event, triggered after the control is added to the page and has been initialized. You can use this event for extra setup beyond setting properties in markup. </span><span style="color:black;mso-themecolor:text1">The signature of the handler function is the same as any other Wijmo event handlers.</span>

```auto
<script setup>
import { ref } from 'vue'
import { WjInputNumber } from '@mescius/wijmo.vue2.input';
const count = ref(3) // variables
//event-handlers
function initializedCtrl(s,e){
console.log("Control initialized event triggered!");
}</script>
<template>
<wj-input-number v-model:value="count" :initialized="initializedCtrl">
</wj-input-number>
</template>
```