vue.js自定义函数方法
分享知识http://www.fedrobots.com/?search=224450我来纠错<div id="example">
<p v-for="item in items" v-bind:title='getName({"name":"羊博士","age":32})' v-bind:data-age='getAge({"name":"羊博士","age":32})'>{{item}},你真棒!</p>
</div>
<script type="text/javascript" src="vue.min.js"></script>
<script type="text/javascript">
var example = new Vue({
el: '#example',
data: {
items: ["前端开发机器人","羊博士"]
},
mounted:function(){
alert('数据渲染完毕了!'); //数据渲染完毕后回调
},
methods:{
getName:function(obj){ //自定义函数获取name
return obj.name;
},
getAge:function(obj){ //自定义函数获取age
return obj.age;
}
}
})
</script>