国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

vue2.0 computed 計算list循環(huán)后累加值的實例

2024-05-06 15:20:59
字體:
供稿:網(wǎng)友

實例如下所示:

<template> <div class="hello">  <h1>{{ msg }}</h1>  <h2>Foo</h2>  <div v-for ="(item, index) in list">  <!--<p>{{item }}</p>-->  <h1 v-show="false">{{a[index] = item.bb}}</h1>   <!-- <h1>index:{{index}}</h1>-->  </div>  <h2>a:{{a}}</h2>  <h2>{{cc}}</h2>  <!--<button v-on:click="cc">點擊</button>--> </div></template><script>export default { name: 'foo', data () {  return {   msg: '這兒是Foo',   list:[{     insertId: 'asfasf252',     bb:29   },{    insertId: '2652',     bb:20   },{    insertId: '996',     bb:18   }],   a:[]  } }, computed:{   cc: function(){     var sum = 0;     for(var i= 0 ;i< this.a.length; i++) {        sum += parseInt(this.a[i]);     }     return sum;   } }}</script><!-- Add "scoped" attribute to limit CSS to this component only --><style scoped>h1, h2 { font-weight: normal;}ul { list-style-type: none; padding: 0;}li { display: inline-block; margin: 0 10px;}a { color: #42b983;}</style>

以上這篇vue2.0 computed 計算list循環(huán)后累加值的實例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持錯新站長站。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 凭祥市| 五河县| 衡东县| 陵川县| 竹山县| 丰城市| 平潭县| 长子县| 平利县| 唐海县| 吴江市| 盘锦市| 清河县| 重庆市| 辛集市| 湘阴县| 旌德县| 那曲县| 岳西县| 尼木县| 广州市| 柘城县| 尼玛县| 名山县| 祁东县| 青浦区| 青河县| 肥乡县| 台前县| 河曲县| 蓬溪县| 汶上县| 武安市| 卢湾区| 玛曲县| 阿克陶县| 昆山市| 武夷山市| 湟源县| 钦州市| 兰西县|