vue.html
<!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=edge">
<title>Document</title>
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.js"></script>
</head>
<body>
<div id="app">
<hello-world></hello-world>
<hello-world></hello-world>
<hello-world></hello-world>
<hello-world></hello-world>
<hello-world></hello-world>
<!-- <hello ></hello> -->
</div>
<script>
// 全局组件
// 局部组件
Vue.component('helloWorld', {
data() {
return {
msg: 'hello world'
}
},
template: `
<div>
<button @click="handleClick">点击</button>
<span>{{ msg }}</span>
</div>
`,
methods: {
handleClick() {
this.msg = 'haha';
}
}
})
const vm = new Vue({
el: '#app',
data: {
},
components: {
'helloWorld': {
template: `<div>hello</div>`
}
}
})
// new Vue({
// el: '#app1',
// })
</script>
</body>
</html>