<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>vue</title>
<link rel="stylesheet" type="text/css" href="beginner.css">
<script type="text/javascript" src="vue.js"></script>
<script type="text/javascript" src="beginner.js"></script>
</head>
<body>
<div id="temp">
<ol>
<htz v-for="site in sites" v-bind:message="site"></htz>
</ol>
</div>
<script>
var vm=new Vue({
el:'#temp',
data:{
val:'',
source:'你是zhou吗',
sites:[
{a:'htzz'},
{a:'19岁'},
{a:'女'}
]
},
components:{
'htz':{
props:['message'],
template:'<li>{message.a}}</li>'
}
}
});
</script>
</body>
</html>
预期结果:
1.htz
2.19岁
3.女
template:'<li>{message.a}}</li> '
这少了个 “{” 括号吧
[Vue tip]: : component lists rendered with v-for should have explicit keys. See https://vuejs.org/guide/list.html#key for more info.
(found in )---- 这是我电脑运行的结果
因为在组件中,使用v-for循环的时候,如果 v-for 有问题必须指定 唯一的 字符串/数字 类型 :key 值