当前位置: 首页 > news >正文

个人网站设计作品展示今天新闻头条最新消息

个人网站设计作品展示,今天新闻头条最新消息,网站导航类型,中国建设人才信息网站查询之前测试了很多JS引擎,都只支持es5语法,不支持执行es6,测试了下微软的V8反正能跑通,应该是支持的。还得是微软呀。 如图:安装相关包: 这是参考的官方V8代码 using Microsoft.ClearScript.JavaScript; us…

之前测试了很多JS引擎,都只支持es5语法,不支持执行es6,测试了下微软的V8反正能跑通,应该是支持的。还得是微软呀。

如图:安装相关包:
在这里插入图片描述
这是参考的官方V8代码

using Microsoft.ClearScript.JavaScript;
using Microsoft.ClearScript.V8;
using Microsoft.ClearScript;
using System.Security.Cryptography;using (var engine = new V8ScriptEngine()){// 指定JavaScript文件路径string filePath = @"D:\test\CallJS\CallJS\test.js";// 读取JavaScript文件内容string javascriptCode = File.ReadAllText(filePath);// expose a host typeengine.Execute("var window = this;");engine.AddHostType("Console", typeof(Console));var type = "mp3";var mid = 440613;var para = $"corp=kuwo&p2p=1&type=convert_url2&sig=0&format={type}&rid={mid}";string str = "Console.WriteLine(encryptQuery('112233'))";string str1 = "Console.WriteLine(encryptQuery('para'))".Replace("para", para);engine.Execute(javascriptCode + C#有偿群:927860652);engine.Execute(javascriptCode + str1);engine.Execute("Console.WriteLine('{0} is an interesting number.', Math.PI)");// expose a host objectengine.AddHostObject("random", new Random());engine.Execute("Console.WriteLine(random.NextDouble())");// expose entire assembliesengine.AddHostObject("lib", new HostTypeCollection("mscorlib", "System.Core"));engine.Execute("Console.WriteLine(lib.System.DateTime.Now)");// create a host object from scriptengine.Execute(@"birthday = new lib.System.DateTime(2007, 5, 22);Console.WriteLine(birthday.ToLongDateString());");// use a generic class from scriptengine.Execute(@"Dictionary = lib.System.Collections.Generic.Dictionary;dict = new Dictionary(lib.System.String, lib.System.Int32);dict.Add('foo', 123);");// call a host method with an output parameterengine.AddHostObject("host", new HostFunctions());engine.Execute(@"intVar = host.newVar(lib.System.Int32);found = dict.TryGetValue('foo', intVar.out);Console.WriteLine('{0} {1}', found, intVar);");// create and populate a host arrayengine.Execute(@"numbers = host.newArr(lib.System.Int32, 20);for (var i = 0; i < numbers.Length; i++) { numbers[i] = i; }Console.WriteLine(lib.System.String.Join(', ', numbers));");// create a script delegateengine.Execute(@"Filter = lib.System.Func(lib.System.Int32, lib.System.Boolean);oddFilter = new Filter(function(value) {return (value & 1) ? true : false;});");// use LINQ from scriptengine.Execute(@"oddNumbers = numbers.Where(oddFilter);Console.WriteLine(lib.System.String.Join(', ', oddNumbers));");// use a dynamic host objectengine.Execute(@"expando = new lib.System.Dynamic.ExpandoObject();expando.foo = 123;expando.bar = 'qux';delete expando.foo;");// call a script functionengine.Execute("function print(x) { Console.WriteLine(x); }");engine.Script.print(DateTime.Now.DayOfWeek);// examine a script objectengine.Execute("person = { name: 'Fred', age: 5 }");Console.WriteLine(engine.Script.person.name);// read a JavaScript typed arrayengine.Execute("values = new Int32Array([1, 2, 3, 4, 5])");var values = (ITypedArray<int>)engine.Script.values;Console.WriteLine(string.Join(", ", values.ToArray()));}

稍微看下官网案例,就知道怎么用了。

再记录下es6转es5步骤:

1.npm执行以下命令:
npm install -g babel-cli 安装babel

2.查看版本 babel --version

3.初始化项目
执行npm init -y

4.安装转换包 npm install --save-dev babel-preset-es2015

5.转为新es5语法文件 babel src -d dist

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
记得把要转换的文件放在项目根目录,我把js文件放在根目录下的src文件夹中,然后创建.babelrc配置文件在根目录中
内容如下:

{"presets": ["es2015"],"plugins": []
}

在这里插入图片描述

然后会在根目录生成新的dist文件夹,es5版本的JS在里面。

http://www.tj-hxxt.cn/news/80896.html

相关文章:

  • 温州哪里可以做企业网站宁波seo快速优化教程
  • 求一个全部用div做的网站搜索大全引擎地址
  • 网站服务器不稳定免费打广告平台有哪些
  • 中文儿童网站模板排名查询系统
  • wordpress 头部 固定江苏搜索引擎优化
  • 西红柿怎么做网站山东seo费用多少
  • 手机网站分页重庆seo推广服务
  • 深圳蕾奥规划设计公司网站关键字
  • 网站建设与网络营销2021年网络十大关键词
  • 桥头做网站爱站网seo综合查询工具
  • 包装设计网站欣赏无锡优化网站排名
  • 餐饮网站开发方案地推
  • 旅游网页设计作品欣赏班级优化大师官网登录
  • 网站托管解决方案东莞网站推广策划
  • 无锡营销型网站贵州萝岗seo整站优化
  • wordpress插件配置文件seo 推广
  • 门户网站开发怎么收费网络软文营销案例
  • 使用vue做的商城网站电商培训班一般多少钱一个月
  • 国外网站问题app推广营销
  • 最好的公文写作网站百度网址大全官方下载
  • 中国建设监理工程协会网站google推广有效果吗
  • 金昌市住房和城乡建设局网站短视频seo营销系统
  • 做淘宝网站要会程序吗刚刚中国出啥大事了
  • 重庆哪里有做网络推广网站seo技术
  • dreamwear做网站步骤枫林seo工具
  • 东莞做网站电话百度帐号注册
  • js企业网站模板北京seo经理
  • 注册贸易公司流程及费用seo综合优化公司
  • 截图京东图片做网站产品推广外包
  • 烟台企业宣传片制作公司seo检测