# Getting Started ## Table of Contents - [Install Vue 2](#install-vue-2) - [Installation](#installation) - [Using the package manager](#using-the-package-manager) - [npm](#npm) - [How to use the calendar](#how-to-use-the-calendar) - [JavaScript](#javascript) - [Importing modules](#importing-modules) - [Loading bundle files for legacy browsers](#loading-bundle-files-for-legacy-browsers) - [CSS](#css) - [Vue](#vue) - [Props](#props) - [Events](#events) - [Methods](#methods) - [getRootElement](#getrootelement) - [getInstance](#getinstance) - [Basic usage](#basic-usage) - [Disable to collect hostname for Google Analytics(GA)](#disable-to-collect-hostname-for-google-analyticsga) ## Install Vue 2 To use TOAST UI Calendar for Vue, [Vue 2](https://v2.vuejs.org/) should be installed. Vue 3 is not supported. ## Installation TOAST UI products can be used by using the package manager or by directly downloading the source code. However, it is recommended to use a package manager. ### Using the package manager TOAST UI products are registered in the [npm](https://www.npmjs.com/) package registry. You can easily install packages using CLI tools provided by each package manager. To use npm, you need to install [Node.js](https://nodejs.org) in advance. #### npm ```sh npm install @toast-ui/vue-calendar # latest version npm install @toast-ui/vue-calendar@ # specific version ``` ## How to use the calendar ### JavaScript #### Importing modules There are three ways to import TOAST UI Calendar for Vue depending on the environment. ```js /* ES6 module in Node.js environment */ import Calendar from '@toast-ui/vue-calendar'; ``` ```js /* CommonJS in Node.js environment */ const Calendar = require('@toast-ui/vue-calendar'); ``` ```js /* in the browser environment namespace */ const Calendar = tui.VueCalendar; ``` #### Loading bundle files for legacy browsers TOAST UI Calendar for Vue provides a separate bundle file for legacy browsers. The basic bundle provides stable support for the latest two versions of the modern browser. However, the basic bundle does not include a polyfill for IE11, so to support IE11 or similar level of legacy browsers, you need to add the IE11 bundle that includes a polyfill as follows. Since the bundle size of IE11 is about 2x larger than that of the default bundle, you must take care not to increase the bundle size unnecessarily by considering the range of support. ```js /* ES6 module in Node.js environment */ import Calendar from '@toast-ui/vue-calendar/ie11'; ``` ```js /* CommonJS in Node.js environment */ const Calendar = require('@toast-ui/vue-calendar/ie11'); ``` ### CSS To use the calendar, you need to add a CSS file of TOAST UI Calendar. You can import CSS files through import and require, or you can import them through CDN. ```js /* ES6 module in Node.js environment */ import '@toast-ui/calendar/dist/toastui-calendar.min.css'; // Stylesheet for calendar ``` ```js /* CommonJS in Node.js environment */ require('@toast-ui/calendar/dist/toastui-calendar.min.css'); ``` ```html ``` ## Vue You can load a calendar component and add it to the `components` in your component or Vue instance. ```html ``` ```js import Calendar from '@toast-ui/vue-calendar'; import '@toast-ui/calendar/dist/toastui-calendar.min.css'; new Vue({ el: '#app', components: { Calendar, }, }); ``` ### Props TOAST UI Calendar for Vue provide props for [options of TOAST UI Calendar](/docs/en/apis/options.md). Each name of props is same with options of Toast UI Calendar except `view` is for `defaultView`. Additionally, it provides a `events` prop to add events. ```html ``` ### Events You can use the `v-on` directive to handle the calendar instance events. For more information such as the parameters of each event, see [TOAST UI Calendar Instance Events](/docs/en/apis/calendar.md#instance-events). ```html ``` ### Methods 💡 Click on a method to see more detailed explanations and usage examples. | Method | Description | | --- | --- | | [getRootElement](#getrootelement) | Return the element on which the calendar is mounted. | | [getInstance](#getinstance) | Return the calendar instance. | #### getRootElement - Type: `getRootElement(): HTMLDivElement` - Returns: `HTMLDivElement` - the element on which the calendar is mounted Return the element on which the calendar is mounted. #### getInstance - Type: `getInstance(): Calendar` - Returns: `Calendar` - the calendar instance Return the calendar instance. You can use this to call the [calendar instance methods](/docs/en/apis/calendar.md#instance-methods). ```html ``` ## Basic usage ### Disable to collect hostname for Google Analytics(GA) [TOAST UI Calendar](https://github.com/nhn/tui.calendar) applies [GA](https://analytics.google.com/analytics/web/) to collect statistics on open source usage to see how widespread it is around the world. This serves as an important indicator to determine the future progress of the project. It collects `location.hostname` (e.g. "ui.toast.com") and is only used to measure usage statistics. To disable GA, set the [`usageStatistics` prop](/docs/en/apis/options.md#usagestatistics) to `false`: ```html ```