这是我的代码可以帮助它如何正确编写切片功能
ul class="procedures" ng-app ng-controller="sample">
<li ng-repeat="procedure in procedures">
<h4><a href="#" ng-click="showDetails = ! showDetails " >{{procedure.definition}} </a></h4>
<div class="procedure-details" ng-show="showDetails">
<p>Number of patient discharges: {{procedure.discharged}}</p>
</div>
</li>
答案 0 :(得分:4)
或者:
{inputs: state.inputs.filter((_, i) => i !== action.index))
答案 1 :(得分:3)
将数组切割到索引,并将其连接到索引+ 1以后的切片:
{
inputs: state.inputs.slice(0, action.index).concat(state.inputs.slice(action.index + 1))
}
如果你使用ES6,你可以这样做而不是concat:
{
inputs: [...state.inputs.slice(0, action.index), ...state.inputs.slice(action.index + 1)]
}