facebook twitter hatena line email

「Javascript/vue/helloworld」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(サンプル)
(サンプル)
 
(同じ利用者による、間の2版が非表示)
行7: 行7:
 
==サンプル==
 
==サンプル==
 
helloworld.html
 
helloworld.html
<pre>
+
<pre>
 
<!DOCTYPE html>
 
<!DOCTYPE html>
 
<html lang="ja">
 
<html lang="ja">
行16: 行16:
 
   <body>
 
   <body>
 
     <div id="column1">
 
     <div id="column1">
       <p>{{text}}</p>
+
       <p>{{text1}}</p>
       <p><span v-text="text"></span></p>
+
       <p><span v-text="text1"></span></p>
 
     </div>
 
     </div>
     <script src="helloworld.js"></script>
+
     <script src="helloworld.js?1234"></script>
 
   </body>
 
   </body>
 
</html>
 
</html>
 
</pre>
 
</pre>
  
<pre>
+
<nowiki>
{{text}} or <span v-text="text"></span>
+
{{text1}} or <span v-text="text1"></span>
</pre>
+
</nowiki>
 
で表示する
 
で表示する
  
 
helloworld.js
 
helloworld.js
<pre>
+
<pre>
 
new Vue({
 
new Vue({
 
   el: '#column1',
 
   el: '#column1',
 
   data: {
 
   data: {
     text: 'ほげほげ'
+
     text1: 'ほげほげ'
 
   }
 
   }
 
});
 
});
 
</pre>
 
</pre>

2018年4月13日 (金) 17:45時点における最新版

vueのscriptロード

本番用

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

デバッグ用

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

サンプル

helloworld.html

<!DOCTYPE html>
<html lang="ja">
  <head>
    <meta charset="utf-8">
    <script src="https://unpkg.com/vue@2.4.4/dist/vue.min.js"></script>
  </head>
  <body>
    <div id="column1">
      <p>{{text1}}</p>
      <p><span v-text="text1"></span></p>
    </div>
    <script src="helloworld.js?1234"></script>
  </body>
</html>

{{text1}} or <span v-text="text1"></span> で表示する

helloworld.js

new Vue({
  el: '#column1',
  data: {
    text1: 'ほげほげ'
  }
});