[英]Running Less.js on C#/Javascript.net/V8
I'm trying to run less.js in a C# application. 我正在尝试在C#应用程序中运行less.js。 I tried running the default distro using JavaScript.net but I'm getting window is undefined error.
我尝试使用JavaScript.net运行默认发行版,但我得到的窗口是未定义的错误。 I think that is caused due to this not being run in a browser but on a JS engine.
我认为这是由于这不是在浏览器中运行而是在JS引擎上运行。 Is there any workaround / any pointers to resources that can help?
是否有任何解决方法/任何可以帮助的资源指针?
You should probably run .Less instead. 你可能应该运行.Less 。 If I understand correctly, you are trying to run less.js on the server through a Javascript interpreter.
如果我理解正确,你试图通过Javascript解释器在服务器上运行less.js。 Why not just skip the interpreter and run LESS conversion using all .NET code?
为什么不跳过解释器并使用所有.NET代码运行LESS转换? Way less pain and overhead.
减少痛苦和开销。
This is more a guess than a real answer but I will try to help so please don't downvote if it is wrong. 这更像是一个猜测,而不是一个真正的答案,但我会尽力帮助,所以如果它是错的,请不要低估。 But according to the documentation (I have never worked with Javascript.net) the following is valid:
但根据文档(我从未使用过Javascript.net),以下内容有效:
// Initialize the context
JavascriptContext context = new JavascriptContext();
// Setting the externals parameters of the context
context.SetParameter("console", new SystemConsole());
context.SetParameter("message", "Hello World !");
context.SetParameter("number", 1);
// Running the script
context.Run("var i; for (i = 0; i < 5; i++) console.Print(message + ' (' + i + ')'); number += i;");
// Getting a parameter
Console.WriteLine("number: " + context.GetParameter("number"));
Maybe you should set the window as a parameter to the context ala this: 也许您应该将窗口设置为上下文的参数:
context.SetParameter("window", new YourWindow());
And insure the window your providing have the same attributes/methods/etc. 并确保您提供的窗口具有相同的属性/方法/等。 as the standard browser window.
作为标准的浏览器窗口。
Addition You could try and implement a simple window which just writes to the console whenever some function is called on it. 添加您可以尝试实现一个简单的窗口,只要在其上调用某个函数时,该窗口就会写入控制台。 Unless of cause, Javascript.Net gives you a window wrapper (does not seem like it though)
除非有原因,Javascript.Net会给你一个窗口包装器(虽然看起来不像)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.