案例:Vue.js案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<meta charset="utf-8">
5
<title>Vue 测试实例 - W3xue教程(w3xue.com)</title>
6
<script src="//unpkg.com/vue/dist/vue.js"></script>
7
</head>
8
<body>
9
<div id="app">
10
    <W3xue></W3xue>
11
</div>
12
13
<script>
14
var Child = {
15
  template: '<h1>自定义组件!</h1>'
16
}
17
18
// 创建根实例
19
new Vue({
20
  el: '#app',
21
  components: {
22
    // <W3xue> 将只在父模板可用
23
    'W3xue': Child
24
  }
25
})
26
</script>
27
</body>
28
</html>