LoginSignup
0
2

More than 1 year has passed since last update.

#Vue の初心者向けチュートリアルが面倒なので、1個のHTMLファイルにまとめて動作確認する ( はじめに - Vue.js )

Last updated at Posted at 2020-02-16

チュートリアル

はじめに — Vue.js

手順

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

<body style="font-size: 150%;">
  <div id="app"></div>

  <hr>

  <div id="app-2">
    <span v-bind:title="message">
      Hover your mouse over me for a few seconds
      to see my dynamically bound title!
    </span>
  </div>

  <hr>

  <div id="app-3">
    <span v-if="seen">Now you see me</span>
  </div>

  <hr>

  <div id="app-4">
    <ol>
      <li v-for="todo in todos">
        {{ todo.text }}
      </li>
    </ol>
  </div>

  <hr>

  <div id="app-5">
    <p>{{ message }}</p>
    <button v-on:click="reverseMessage">Reverse Message</button>
  </div>

  <hr>

  <div id="app-6">
    <p>{{ message }}</p>
    <input v-model="message">
  </div>
</body>

<script>
new Vue({
  template: '<p></p>',
  data:{ msg:'hello world!' }
}).$mount('#app')

var app2 = new Vue({
  el: '#app-2',
  data: {
    message: 'You loaded this page on ' + new Date().toLocaleString()
  }
})

var app3 = new Vue({
  el: '#app-3',
  data: {
    seen: true
  }
})

var app4 = new Vue({
  el: '#app-4',
  data: {
    todos: [
      { text: 'Learn JavaScript' },
      { text: 'Learn Vue' },
      { text: 'Build something awesome' }
    ]
  }
})

var app5 = new Vue({
  el: '#app-5',
  data: {
    message: 'Hello Vue.js!'
  },
  methods: {
    reverseMessage: function () {
      this.message = this.message.split('').reverse().join('')
    }
  }
})


var app6 = new Vue({
  el: '#app-6',
  data: {
    message: 'Hello Vue!'
  }
})

</script>


これをてきとうなパスに保存して開くこと。

Macならテキストをコピーした後に

pbpaste > ~/vue-start.html && open ~/vue-start.html

とか。

動作例

image

Original by Github issue

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

0
2
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
0
2