未捕获的 SyntaxError:在严格模式代码中,函数只能在顶层声明或立即在另一个函数中声明 [英] Uncaught SyntaxError: In strict mode code, functions can only be declared at top level or immediately within another function

查看:39
本文介绍了未捕获的 SyntaxError:在严格模式代码中,函数只能在顶层声明或立即在另一个函数中声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,当我在开发者模式下运行这个项目(grunt 服务器)https://github.com/kennethlynne/generator-angular-xl 一切正常,但是当我在生产模式(grunt build)下运行它时,我得到一个 `

Hello when I run this project in Developer mode (grunt server) https://github.com/kennethlynne/generator-angular-xl everything is ok but when I run it in production mode (grunt build) I get an `

未捕获的语法错误:在严格模式代码中,函数只能被在顶层声明或立即在另一个函数中声明

Uncaught SyntaxError: In strict mode code, functions can only be declared at top level or immediately within another function

有人知道这是怎么回事吗?谢谢,

Anyone have any idea what's going on? Thanks,

附言.我发布了一个项目链接而不是代码,因为 JS 被分成许多文件.

Ps. I posted a link to the project instead of code since the JS is split in many files.

推荐答案

我解决这个问题的方法是删除最终缩小脚本中 jquery 上方的 'use strict'.另一种方法可以将 jQuery 版本更改为一个没有严格错误的版本

The way I solved the problem was by removing the 'use strict' that was above the jquery in the final minified script. Another way can be changing the jQuery version to one without the strict bug

毕竟这是 1.11 版上的 jQuery 缩小错误,一个简单的解决方法是转到您的 Grunt 文件并注释掉该行

After all it was a jQuery minification error on version 1.11, and an easy fix for this is to go to your Grunt file and comment out the line

banner: "'use strict';\n"

这篇关于未捕获的 SyntaxError:在严格模式代码中,函数只能在顶层声明或立即在另一个函数中声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆