suchen

Heim  >  Fragen und Antworten  >  Hauptteil

angular.js - angularjs 模板布局方法哪种效率比较高呢?



<p class="asse-p" ng-if="data.shopClass=='1'"><span class="assess1" ></span</p>
<p class="asse-p" ng-if="data.shopClass=='2'"><span class="assess2" ></span></p>
<p class="asse-p" ng-if="data.shopClass=='3'"><span class="assess3" ></span></p>
<p class="asse-p" ng-if="data.shopClass=='4'"><span class="assess4" ></span></p>
<p class="asse-p" ng-if="data.shopClass=='5'"><span class="assess5" ></span></p>
            

 <p class="asse-p">
     <span ng-class="data.shopClass== 1 ? 'assess1' : (data.shopClass== 2?'assess2' : (data.shopClass== 3?'assess3':(data.shopClass== 4?'assess4':'assess5')))" ></span>
 </p>
 
 以上两种方法哪种效率比较高呢????????用哪种比较好???
为情所困为情所困2744 Tage vor707

Antworte allen(1)Ich werde antworten

  • 为情所困

    为情所困2017-05-15 17:01:32

    哪种都不好

    用这个不是简洁多了

            <p class="asse-p"><span class="assess{{data.shopClass}}"></span</p>

    Antwort
    0
  • StornierenAntwort