这个ccl不是组件的,而是他爹的方法。
你要在他爹的methods里面定义:
Vue.component('child',{
template: '
{{title}}hello component.
',
props: ['message'],
})
var father=new Vue({
el:"#example",
data:{
"component_name":'child'
},
methods:{
ccl:function(){
/**/
}
}
})
理解好vue模板里面的作用域,就能够知道为什么了。。。
========2016年9月22日16:01:39 补充===========
怎么将父组件的数据传递给子组件
这个文档有说啊,用props:
然后父组件在data里面弄个msg的字段
Vue.component('child',{
template: '
{{title}}hello component.
',
props: ['fatherMassage'],
ready:function(){
console.log(this.fatherMassage.list)
}
})
var father=new Vue({
el:"#example",
data:{
"component_name":'child',
"msg":{
list:[xxx,xxx,xx,xx,x],
data:[{
xxx:xxx,
xxx:xx
},{
xxx:xx,
xxx:xx
}]
}
},
methods:{
ccl:function(){
/**/
}
}
})
vue的作者尤大的文档写的很详细啦~~~~认真看下都会明白的