<test v-for="(item,index) in prolist" v-bind:res="item" :index="index"></test>
var comp = {
template: "<p id="getid(index)">{{res.F_Id}}</p>",
props: ['res', 'index'],
methods: {
getid:function(index){
return "pro_"+index;
}
}
}
如何把组件传过去的index 绑定到模板里 p标签的id ?怎么写求教
var comp = {
template: "<p id="getid(index)">{{res.F_Id}}</p>",
props: ['res', 'index'],
methods: {
getid:function(index){
return "pro_"+index;
}
}
}
如何把组件传过去的index 绑定到模板里 p标签的id ?怎么写求教
解决方案 »
- extJS 函数问题
- 请教一个正则表达式?
- 在IE下 一个change事件会触发两次?
- 各位大虾,小弟有个超级重要的问题需要请教,浏览器卡死的问题……!%……!!!!
- !如果在条件判断语句中只写这条的语句“document.getElementById”,会返回什么呢?
- form.elements[n].BackColor="#ff9999"; 给指定的文本框设背景颜色,没反应?
- 问题:"Msxml2.Xmlhttp”的ActiveX对象访问后台页面时,提示"没有权限"的问题
- 屏蔽后退怎么解决?
- 不同服务器的JavaScript?
- 各位打虾,在javascript里怎样禁止页面读缓存?
- 为啥外部js不能获取html内的td标签?
- js获取上传文件的绝对路径
var comp = {
template: "<p :id=“getid”>{{res.F_Id}}</p>",
props: ['res', 'index'],
datas: function () {
return {
getid:function(){
return "pro_"+this.index;
}
}
}
template: "<p :id=“getid”>{{res.F_Id}}</p>",
props: ['res', 'index'],
computed: {
function () {
return {
getid:function(){
return "pro_"+this.index;
}
}
}
}
var comp = {
template: "<p :id=“getid”>{{res.F_Id}}</p>",
props: ['res', 'index'],
computed: {
getid: function () {
return "pro_"+this.index;
}
}
}
var comp = {
template: "<p :id='getid'>{{res.F_Id}}</p>",
props: ['res', 'index'],
computed: {
getid: function () {
return "pro_" + this.index;
}
}
}
<test v-for="(item,index) in prolist" :res="item" :index="index"></test>
</div>
<script>
Vue.component('test', {
template: "<p :id='\"pro_\"+index'>{{res.F_Id}}</p>",
props: ['res', 'index']
})
var app = new Vue({
el: '#app',
data: {
prolist: [{F_Id:'A'},{F_Id:'B'}]
}
})
</script>
var comp = {
template: "<p :id='getid'>{{res.F_Id}}</p>",
props: ['res', 'index'],
computed: {
getid: function () {
return "pro_" + this.index;
}
}
}谢谢老哥。这个更简洁了