我可以在没有npm,VS,Node等的情况下为ES6-ES5进行透明,而且只是JS代码本身吗? [英] Can I Transpile for ES6-ES5 without npm, VS, Node, etc. and just the JS code itself somehow?

查看:97
本文介绍了我可以在没有npm,VS,Node等的情况下为ES6-ES5进行透明,而且只是JS代码本身吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让Firefox在ES6中运行Promise但是遇到'let'关键字触发错误;

I am trying to get Firefox to run a Promise in ES6 but run into the 'let' keyword triggering an error;

SyntaxError:let是一个保留标识符

SyntaxError: let is a reserved identifier

更改脚本标记以包含;
type =application / javascript; version = 1.7
不起作用,所以我正在寻求透明代码。

Changing the script tag to include; type="application/javascript;version=1.7" did not work, so I am seeking to Transpile the code.

我的情况是没有任何东西被使用,除了文本编辑器。没有NPM,没有Node或Angular,没有Visual Studio,没有。因此,当我调查编译器时,我看到没有选项让我在没有任何其他工具/编辑器等的情况下透明这些代码。

My situation is that there is nothing being used except a text editor. No NPM, not Node or Angular, no Visual Studio, nothing. So when I investigated the Compilers, I saw no option to let me Transpile this code without any of these other tools/editors/etc.

我有选择吗?不必学习,使用,安装,配置,改编,另一种工具,只是直接透明,还是有一些服务器特定的原因,这是不能做到的?我有什么选择?

Is there an option where I do not have to learn, use, install, configure, adapt, another tool and just Transpile it outright, or is there some server-specific reason that this cannot be done? What ARE my options?

提前致谢!希望有人可以在ES6中学习我并让它与Firefox一起工作,这样它就不会触发错误并按照预期的方式使用'let'。

Thanks in advance! Hoping someone can school me in ES6 and getting it to work with Firefox so it doesn't trigger the errors and use 'let' the way it is intended to be ran.

推荐答案

您可以在浏览器中使用babel-standalone编写ES6

You can write ES6 in the browser with the babel-standalone

<div id="output"></div>
<!-- Load Babel -->
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
<!-- Your custom script here -->
<script type="text/babel">
  const getMessage = () => "Hello World";
  document.getElementById('output').innerHTML = getMessage();
</script>

这篇关于我可以在没有npm,VS,Node等的情况下为ES6-ES5进行透明,而且只是JS代码本身吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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