Skip to content
Mithril.js 2
Main Navigation 가이드API

한국어

English
简体中文
繁體中文
Español
Français
Русский
Português – Brasil
Deutsch
日本語
Italiano
Polski
Türkçe
čeština
magyar

한국어

English
简体中文
繁體中文
Español
Français
Русский
Português – Brasil
Deutsch
日本語
Italiano
Polski
Türkçe
čeština
magyar

외관

Sidebar Navigation

시작하기

설치

간단한 애플리케이션

리소스

JSX

구형 브라우저에서 ES6+ 사용하기

애니메이션

테스트

예제

타사 통합

경로 처리

주요 개념

Virtual DOM 노드

컴포넌트

생명주기 메서드

키

자동 리드로우 시스템

기타

프레임워크 비교

v1.x에서 v2.x로의 마이그레이션

v0.2.x에서 v2.x로 마이그레이션하기

API

이 페이지에서

설치 ​

CDN 및 온라인 플레이그라운드 ​

JavaScript를 처음 접하거나 간단하게 시작하고 싶다면 CDN(콘텐츠 전송 네트워크)을 통해 Mithril.js를 사용할 수 있습니다.

html
<script src="https://unpkg.com/mithril/mithril.js"></script>

로컬 환경 설정 없이 Mithril.js를 사용해 보려면 flems.io/mithril에서 제공하는 온라인 플레이그라운드를 이용하면 됩니다.

npm ​

bash
$ npm install mithril

TypeScript 타입 정의는 DefinitelyTyped에서 제공됩니다. 다음 명령어로 설치할 수 있습니다.

bash
$ npm install @types/mithril --save-dev

로컬 프로젝트 생성 ​

기존 Mithril.js 시작 템플릿을 활용하여 프로젝트를 시작할 수 있습니다.

  • mithril-vite-starter
  • mithril-esbuild-starter
  • mithril-rollup-starter

예를 들어 mithril-esbuild-starter로 시작하려면 다음 명령을 실행합니다.

bash
# 원하는 디렉토리에 템플릿을 복제합니다.
npx degit kevinfiol/mithril-esbuild-starter hello-world

# 생성된 프로젝트 디렉토리로 이동합니다.
cd ./hello-world/

# 의존성 패키지를 설치합니다.
npm install

# 앱을 빌드하고 변경 사항을 감지하여 자동으로 다시 빌드합니다.
npm run dev

esbuild를 이용한 빠른 시작 ​

esbuild 관련 문서는 여기에서 확인할 수 있습니다.

  1. 디렉토리를 npm 패키지로 초기화합니다.
bash
$ npm init --yes
  1. 필요한 도구를 설치합니다.
bash
$ npm install mithril
$ npm install esbuild --save-dev
  1. package.json 파일의 scripts 섹션에 "start" 항목을 추가합니다.

    json
    {
      "...": "...",
      "scripts": {
        "start": "esbuild index.js --bundle --outfile=bin/main.js --watch"
      }
    }

    JSX를 사용하려면 esbuild와 함께 --jsx-factory 및 --jsx-fragment 플래그를 추가할 수 있습니다.

    json
    {
      "...": "...",
      "scripts": {
        "start": "esbuild index.js --bundle --outfile=bin/main.js --jsx-factory=m --jsx-fragment='\"[\"' --watch"
      }
    }
  2. index.js 파일을 생성합니다.

javascript
import m from 'mithril';
m.render(document.getElementById('app'), 'hello world');
  1. index.html 파일을 생성합니다.
html
<!DOCTYPE html>
<body>
  <div id="app"></div>
  <script src="bin/main.js"></script>
</body>
  1. 번들러를 실행합니다.
bash
$ npm run start
  1. 브라우저에서 index.html 파일을 엽니다. 페이지에 hello world 텍스트가 표시됩니다.
Pager
다음간단한 애플리케이션

MIT 라이선스 하에 배포되었습니다.

Copyright (c) 2024 Mithril Contributors

https://mithril.js.org/installation.html

MIT 라이선스 하에 배포되었습니다.

Copyright (c) 2024 Mithril Contributors