「Vue.js」Vueのelとdataオブジェクトのサンプル

書式
new Vue({
el:’要素セレクタ’,
data: {データ名前:値}
}
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!DOCTYPE html>
<html>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<body>
<div id="cft">
<h1>{{ msg }}</h1>
</div>
<script>
//インスタンスの作成
var myObject = new Vue({
/* #cft 要素に対して Vue を適用する */
el: '#cft',
/* message という名前のデータを定義する */
data: {msg: 'study skill arkgame.com'}
})
</script>
</body>
</html>
<!DOCTYPE html> <html> <script src="https://cdn.jsdelivr.net/npm/vue"></script> <body> <div id="cft"> <h1>{{ msg }}</h1> </div> <script> //インスタンスの作成 var myObject = new Vue({ /* #cft 要素に対して Vue を適用する */ el: '#cft', /* message という名前のデータを定義する */ data: {msg: 'study skill arkgame.com'} }) </script> </body> </html>
<!DOCTYPE html>
<html>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<body>

<div id="cft">
  <h1>{{ msg }}</h1>
</div>

<script>
//インスタンスの作成
var myObject = new Vue({
/* #cft 要素に対して Vue を適用する */
  el: '#cft',
  /* message という名前のデータを定義する */
  data: {msg: 'study skill arkgame.com'}
})
</script>

</body>
</html>

 

Vue.js

Posted by arkgame