js這一坨代碼有沒有辦法簡(jiǎn)化下,看著挺尷尬的

科技 未結(jié) 4 1252
最愛吃白米飯
最愛吃白米飯 2022-06-16 17:07

$scope.ezzh_qsw_lines = Math.ceil($scope.ezzh_qsw.length / $scope.cols); $scope.ezzh_zsw_lines = Math.ceil($scope.ezzh_zsw.length / $scope.cols); $scope.ezzh_hsw_lines = Math.ceil($scope.ezzh_hsw.length / $scope.cols); $scope.bsdw_qsw_lines = Math.ceil($scope.bsdw_qsw.length / $scope.cols); $scope.bsdw_zsw_lines = Math.ceil($scope.bsdw_zsw.length / $scope.cols); $scope.bsdw_hsw_lines = Math.ceil($scope.bsdw_hsw.length / $scope.cols); $scope.bgdw_qsw_lines = Math.ceil($scope.bgdw_qsw.length / $scope.cols); $scope.bgdw_zsw_lines = Math.ceil($scope.bgdw_zsw.length / $scope.cols); $scope.bgdw_hsw_lines = Math.ceil($scope.bgdw_hsw.length / $scope.cols); $scope.sgdw_qsw_lines = Math.ceil($scope.sgdw_qsw.length / $scope.cols); $scope.sgdw_zsw_lines = Math.ceil($scope.sgdw_zsw.length / $scope.cols); $scope.sgdw_hsw_lines = Math.ceil($scope.sgdw_hsw.length / $scope.cols); $scope.bghs_qsw_lines = Math.ceil($scope.bghs_qsw.length / $scope.cols); $scope.bghs_zsw_lines = Math.ceil($scope.bghs_zsw.length / $scope.cols); $scope.bghs_hsw_lines = Math.ceil($scope.bghs_hsw.length / $scope.cols); $scope.sghs_qsw_lines = Math.ceil($scope.sghs_qsw.length / $scope.cols); $scope.sghs_zsw_lines = Math.ceil($scope.sghs_zsw.length / $scope.cols); $scope.sghs_hsw_lines = Math.ceil($scope.sghs_hsw.length / $scope.cols);

4條回答
  •  流浪人生_2020
    2022-06-16 17:51

    重復(fù)的代碼都是可以消除的,要寫好代碼,就是消除重復(fù)和提高表達(dá)力

提交回復(fù)