5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

HTMLファイルだけでVue.jsを利用する

Posted at

多分これが一番シンプルだと思います。

実装

<html>
  <body>
    <div id="app">
      <custom-component :msg='msg' v-on:hello-hoge="msg = 'OK!!!'" />
    </div>

    <script type="text/x-template" id="custom-component">
      <div>
        <span>{{msg}}</span>
        <button v-on:click="$emit('hello-hoge')">ボタン</button>
      </div>
    </script>

    <script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>

    <script>
      Vue.component("customComponent", {
        props: ["msg"],
        template: "#custom-component",
      })
    </script>

    <script>
      new Vue({
        el: "#app",
        data: {
          msg: 'hoge'
        },
      })
    </script>
  </body>
</html>

まとめ

ライブラリなどは利用しにくいので、ちょっとした検証をする際には便利かも。

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?