鍍金池/ 問答/HTML/ vue這個代碼哪里不對?

vue這個代碼哪里不對?

Failed to mount component: template or render function not defined.
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <script src="vue.js"></script>
</head>
<body>
  <template id="test">
    <div>
       aaaa<slot name="age"></slot>
    </div>
  </template>

  <div id="app">
    <show>
       <span slot="age">{{age}}</span>
    </show>
  </div>
  <script>
  var user={
      template:"#test",
  }
  new Vue({
    el:"#app",
    data:{
       age:22
    },
    components:{
      "show":test,
    },
  })
  </script>
</body>
</html>
回答
編輯回答
夕顏

組件基礎 -- Vue.js

看起來你并沒有注冊組件,或者說

components: {
    "show": test,
}

這里的 test 并不是一個有效的組件對象。

2018年5月20日 17:24
編輯回答
六扇門

一個頁面所有的html都應該寫到template里你上面那個div都寫到外面去了

2017年12月18日 03:29