Vue - 在v-repeat中使用计算属性
生活随笔
收集整理的這篇文章主要介紹了
Vue - 在v-repeat中使用计算属性
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1、從后端獲取JSON數據集合后,對單條數據應用計算屬性,在Vue.js 0.12版本之前可以在v-repeat所在元素上使用v-component指令
在Vue.js 0.12版本之后使用自定義元素組件實現v-repeat中使用計算屬性
1 <div id="items"> 2 <my-item v-repeat="items" inline-template> 3 <button>{{fulltext}}</button> 4 </my-item> 5 </div> 6 7 <script type="text/javascript"> 8 var items = [ 9 {number : 1,text : 'one'}, 10 {number : 2,text : 'two'} 11 ] 12 13 var vue = new Vue({ 14 el : '#items', 15 16 data : {items : items}, 17 18 component : { 19 'my-item' : { 20 replace : true , 21 computed : { 22 fulltext : function(){ 23 return 'item' + this.text 24 } 25 } 26 } 27 } 28 }) 29 </script>?
轉載于:https://www.cnblogs.com/zhanghuiyun/p/6225709.html
總結
以上是生活随笔為你收集整理的Vue - 在v-repeat中使用计算属性的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: J2EE进阶(十五)MyEclipse反
- 下一篇: Mysql 客户端查询结果如何保存到本地