守着一只汪
在 Github 上骚扰了大神,但是发现不是 avalon 的问题,(°ー°〃) 应该是语法问题,$template 里没法直接用字符串和 : 符号,把要用的字符串先定义一下就能用了哦!function addPageVm(i) { $.component("ms:div", { $replace: 1, $ready: function() { console.log("构建完成") }, add: "ADD", addSign: '+', minusSign: '-', time: function (index) { var time = new Date(i.data.list[index].created_at/1000), Y = time.getFullYear() + '-', M = (time.getMonth()+1 < 10 ? '0'+(time.getMonth()+1) : time.getMonth()+1) + '-', D = time.getDate() + ' ', h = time.getHours() + ':', m = time.getMinutes() + ':', s = time.getSeconds(); return Y+M+D+h+m+s }, $template: '<div class="single" ms-repeat="list" ms-visible="el.oper_status === add">' + '<p class="head">{{el.description}}</p>' + '<p class="detail" ms-text="time($index)"></p>' + '<div ms-if="el.oper_status === add" class="sub-num add-num" >' + '<span class="symbol">{{el.oper_status === add ? addSign : minusSign}} </span>' + '<span>{{el.oper_point}}</span></div>' + '<div ms-if="el.oper_status !== add" class="sub-num" >' + '<span class="symbol">{{el.oper_status !== add ? addSign : minusSign}} </span>' + '<span>{{el.oper_point}}</span></div>' + '<ms:text /></div>' }); $.scan(); }