<!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">
<script src="./vue_expansion.js"></script>
<title>component</title>
</head>
<body>
<div id="root">
<child :name1="name1">
<p>{{ name }}</p>
</child>
</div>
<script>
Vue.component('child', {
props: ['name1'],
template: '<div><div>{{ name1 }}</div><slot></slot></div>'
})
let vm = new Vue({
el: '#root',
data: {
name: 'Zhao',
name1: 'ZiLin'
}
})
</script>
</body>
</html>
写完我明白了,谢谢老师