<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
</head>
<body>
<div class="app">
<txx v-for="qwer in items" v-bind:qin="qwer">
</txx>
</div>
<script>
Vue.component("txx",{
props:['qin'],
template: '<P>{{qin}}</P>'
});
var vm = new Vue({
el: ".app",
data: {
items:[
"ohaev","chaunld","cjphoqgyif"
]
}
});
</script>
</body>
</html>
v-for="qwer in items"从items中循环数据并赋给qwer,qwer通过v-bind:qin把参数传给qin,
template: '<P>{{qin}}</P>'接收qin传的参数,<txx>调模板显示出来,实现遍历数据(props:['qin']相当于new一个变量)
标签:vue,bind,props,qwer,qin,template,items From: https://www.cnblogs.com/tttx/p/17173945.html