鍍金池/ 問答/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>
回答
編輯回答
懶洋洋

template要放在參數(shù)里,再一個#test對應(yīng)的標簽是這樣的:
<script type="x-template" id="test">

看看官網(wǎng)的例子:
https://cn.vuejs.org/v2/examp...

文檔:
https://cn.vuejs.org/v2/api/#...

new Vue({
    el:"#app",
    data:{
       age:22
    },
    
    template:"#test",   
    
    components:{
      "show":test,
    },
  })
2017年9月6日 13:30
編輯回答
司令

vue的組建不是這么用的

2017年1月17日 02:49
編輯回答
情未了

可以看下Vue.component, Vue.extend 2個Api,相關(guān)修改的demohttps://github.com/huixisheng...。

建議看下Vue 單文件組件

2018年7月23日 15:47
編輯回答
傲寒

建議從頭學(xué)習(xí),你這完全就不對

2018年6月2日 03:07