search

Home  >  Q&A  >  body text

javascript - vuejs新手{{app}}解析出来为空,代码已贴,求大侠解惑?

<!DOCTYPE html>
<html lang="en">
  <head>
    <!-- Required meta tags always come first -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="x-ua-compatible" content="ie=edge">

    <!-- ratchet CSS -->
    <link href="./bower_components/ratchet/dist/css/ratchet.css" rel="stylesheet">
  </head>
  <body>
  <p id="app">
    <h1>{{app}}</h1>
    <input type="text" v-model="app">
    <input type="button" v-on:click="test" value="点击事件">
  </p>
    
    <!-- Vue JS. -->
    <script src="./bower_components/vue/dist/vue.js"></script>
    <script data-main="main" src="//cdn.bootcss.com/require.js/2.1.22/require.js"></script>
    <script>
      new Vue({
        el: '#app',
        data: {
            message: 'Hello Vue.js!'
        },
        methods:{
          test: function (argument) {
            alert('1');
          }
        }
      });
    </script>
  </body>
</html>
PHPzPHPz2902 days ago150

reply all(1)I'll reply

  • 迷茫

    迷茫2017-04-10 16:56:39

    v-model="app",而你并没有在data中给定app键值

    <h1>{{app}}</h1>

    改成

    <h1>{{message}}</h1>

    reply
    0
  • Cancelreply