vue全局注册组件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
</head>
<body>
<div id="app">
<zmr-Qxt></zmr-Qxt>
</div>
<script>
Vue.component('zmrQxt', {
template: `<h1 @click='one'>赵梦冉{{name}}</h1>`,
data() {
return {
name: '邱勋涛'
}
},
methods: {
one() {
console.log('one')
console.log(this.two)
},
two() {
console.log('two')
},
there() {
console('this')
}
}
})
let vm = new Vue({
el: "#app"
})
</script>
</body>
</html>
vue局部注册组件
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
</html>
</title>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
</head>
<body>
<div id="app">
<qxt></qxt>
</div>
<script>
var zmr = {
template: '<h1>彼方尚有荣光在!</h1>'
}
new Vue({
el: '#app',
components: {
'qxt': zmr
}
})
</script>
</body>
</html>