Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What is going on with this article?
@wafuwafu13

【Riot.js】【訂正版】cdnで楽々Hello World

More than 1 year has passed since last update.

Riot.jsの勉強をしています。
npmやwebpackを使う方法もあるのですが、より簡単なcdnを使う方法で学習を進めていきます。

まずは、任意のフォルダにindex.htmlapp.riotを用意します。

index.html

<!doctype html>

<html>
  <head>
    <title>Riot todo</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
  </head>

  <body>

    <app></app>

    <script src="app.riot" type="riot"></script>
    <script src="https://cdn.jsdelivr.net/npm/riot@4/riot+compiler.min.js"></script>

    <script>
      riot.compile().then(() => {
        riot.mount('app', {
          title: 'Hello World',
        })
      })
    </script>
  </body>
</html>
app.riot
<app>
  <h3>{ props.title }</h3>
</app>

このままhtmlファイルをchromeにおくと、URL scheme must be "http" or "https" for CORS request.といったエラーが出てしまうので、以下の手順でローカルサーバーを立てます。

$ npm install -g live-server
$ cd <index.htmlとapp.riotがあるフォルダ>
$ live-server .
# http://localost:8080/でブラウザからアクセス可能

これで画面にHello Worldと表示されます!!

[参考]
https://github.com/riot/examples
ChromeにてAjaxでローカルファイルにアクセス

0
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
wafuwafu13
メモ感覚で書いてます。

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
0
Help us understand the problem. What is going on with this article?