它给出了意想不到的缩进错误。任何想法?任何一个?

时间:2018-01-12 11:52:19

标签: coffeescript

下面是我的咖啡脚本。它出现“意外缩进”错误。 任何人都可以猜到错误是什么?

evaluateContainerRules: ( rules, containerType ) ->
    deferred = Ext.create( 'Deft.promise.Deferred' )

    searchCriteria = []
    for rule in rules
        if rule.searchTerms? and rule.searchTerms.length > 0
            searchCriteria.push( rule )
            console.log 'rule'
            console.log 'searchCriteria'

      if searchCriteria.length <= 0
             emptyRules = 
               [
              {
                 searchOption: 'EMPTY_RULE'
                searchTerms: true
        }
        ]
        console.log 'emptyRules'
        searchCriteria.push( emptyRules )
        searchCriteria.push["Hello"]
        console.log 'searchCriteria'

    store = Ext.create( 'Traverse.core.store.admin.container.ContainerMemberSummarySearchStore',
        params: 
            searchCriterias: searchCriteria
            traverseTypeEnums: if containerType is 'device' then [ Traverse.core.enumeration.TraverseType.DEVICE ] else [ Traverse.core.enumeration.TraverseType.TEST ]
    )
    complete = false
    store.on( 
        'load' 
        ( records, operation, success ) ->
            # NOTE: callback is fired multiple times for a paging store, only execute logic during the first call
            if complete
                return
            complete = true
            if success
                deferred.resolve( store )
            else
                store.destroyStore()
                @showError( operation.getError() )
                deferred.reject( operation.getError() )
            return
        scope: @
    )
    store.load()
    return deferred.promise

它的

1 个答案:

答案 0 :(得分:0)

这似乎是编译

的代码的合理重新缩进
evaluateContainerRules: ( rules, containerType ) ->
    deferred = Ext.create( 'Deft.promise.Deferred' )

    searchCriteria = []
    for rule in rules
        if rule.searchTerms? and rule.searchTerms.length > 0
            searchCriteria.push( rule )
            console.log 'rule'
            console.log 'searchCriteria'

        if searchCriteria.length <= 0
            emptyRules = 
                [{
                    searchOption: 'EMPTY_RULE'
                    searchTerms: true
                }]
        console.log 'emptyRules'
        searchCriteria.push( emptyRules )
        searchCriteria.push["Hello"]
        console.log 'searchCriteria'

    store = Ext.create( 'Traverse.core.store.admin.container.ContainerMemberSummarySearchStore',
        params: 
            searchCriterias: searchCriteria
            traverseTypeEnums: if containerType is 'device' then [ Traverse.core.enumeration.TraverseType.DEVICE ] else [ Traverse.core.enumeration.TraverseType.TEST ]
    )
    complete = false
    store.on( 
        'load' 
        ( records, operation, success ) ->
            # NOTE: callback is fired multiple times for a paging store, only execute logic during the first call
            if complete
                return
            complete = true
            if success
                deferred.resolve( store )
            else
                store.destroyStore()
                @showError( operation.getError() )
                deferred.reject( operation.getError() )
            return
        scope: @
    )
    store.load()

希望这有帮助