<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=adge">
<title>Document</title>
<script src="vue.js"></script>
</head>
<body>
<div id="app">
<mycom2></mycom2>
</div>
</body>
<script>
//定义全局的组件方法2
//Vue.component的第二个参数,即接收一个组件的构造函数,同时,也接收一个对象
Vue.component("mycom2",{
//template中需要有HTML便签才会显示出来,并且根元素只能有一个,多个同级元素必须放在根元素里面
template:"<h1>直接在Vue.component中创建组件</h1>"
})
//创建Vue实例,得到ViewModel
var vm=new Vue({
el:"#app",
data:{},
methods:{}
});
</script>
</html>