Grunt构建js错误

时间:2017-04-27 13:42:06

标签: javascript gruntjs

由于我包含了for循环,因此出现此错误:"dependencies": { "@angular/common": "4.1.0", "@angular/compiler": "4.1.0", "@angular/compiler-cli": "^4.1.0", "@angular/core": "4.1.0", "@angular/forms": "4.1.0", "@angular/http": "4.1.0", "@angular/platform-browser": "4.1.0", "@angular/platform-browser-dynamic": "4.1.0", "@angular/platform-server": "^4.1.0", "@angular/router": "4.1.0", "@angular/upgrade": "4.1.0", "core-js": "2.4.1", "es6-shim": "0.35.3", "jquery": "3.2.1", "jquery-ui-npm": "1.12.0", "jsdom": "10.0.0", "marked": "0.3.6", "moment": "2.18.1", "ng2-file-upload": "1.2.1", "ng2-translate": "5.0.0", "ngx-bootstrap": "^1.6.6", "reflect-metadata": "0.1.10", "rxjs": "5.3.0", "tinymce": "4.5.7", "ts-md5": "1.2.0", "zone.js": "0.8.9" }, "devDependencies": { "@types/core-js": "0.9.41", "compression": "1.6.2", "del": "2.2.2", "gulp": "3.9.1", "gulp-clean-css": "3.0.4", "gulp-coffee": "2.3.4", "gulp-concat": "2.6.1", "gulp-if": "2.0.2", "gulp-minify-html": "1.0.6", "gulp-ngc": "^0.3.0", "gulp-npm-files": "0.1.3", "gulp-rev": "7.1.2", "gulp-sass": "3.1.0", "gulp-typescript": "3.1.6", "gulp-uglify": "2.1.2", "gulp-util": "3.0.8", "http-proxy-middleware": "0.17.4", "lite-server": "2.3.0", "path": "0.12.7", "rollup": "^0.41.6", "rollup-plugin-commonjs": "^8.0.2", "rollup-plugin-node-resolve": "^3.0.0", "rollup-plugin-uglify": "^1.0.2", "typings": "2.1.1", "webpack": "2.4.1", "webpack-stream": "3.2.0" }

这是我试图构建的js代码:

Warning: Uglification failed.
Unexpected token: punc (.).

当我尝试构建此文件时,我知道为什么会出现此错误?

1 个答案:

答案 0 :(得分:1)

关闭.后,您有}(点),这会引发错误。请尝试以下代码

chart: {
        type: 'column',
        events: {
            load: function () {
                for (i = 0; i <= captionLabel.length; i++) {
                    var label = this.renderer.label(captionLabel[i]);
                    label.css({
                        width: '400px',
                        fontSize: '9px'
                    })
                        .attr({
                            'r': 2,
                            'padding': 5
                        })
                        .add();

                    label.align(Highcharts.extend(label.getBBox(), {
                        align: 'center',
                        x: 20, // offset
                        verticalAlign: 'bottom',
                        y: 0 // offset
                    }), null, 'spacingBox');

                }

            }
        },
        marginBottom: 120
    }