<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="../js/vue.js"></script>
</head>
<body>
<div id="app">
<!-- 组件里的v-for 必须要有key值的绑定 -->
<boke v-for="(item,index) in items" :key="index" :item="item" :index="index"></boke>
</div>
<script>
Vue.component('boke', {
props: ['item','index'],
data: () => {
return {
message: 'hello world'
}
},
template: "<p>{{message}}--{{item}}===={{index}}</p>",
});
var vm = new Vue({
el: "#app",
data: {
items: {
name: 'zhangsan',
age: 20,
}
}
});
</script>
</body>
</html>