首页 \ 问答 \ IE中的LESS会抛出异常(LESS in IE throws exceptions)

IE中的LESS会抛出异常(LESS in IE throws exceptions)

我正在使用LESSrespond.js来简化新网站的开发。 LESS和回应都非常简洁。 然而,随着IE中的LESS我遇到了很多问题。

对于IE8模式的初学者,我的IE10报告说id不理解“map”。 没问题,我写了一个Array.prototype映射扩展。 然后它说它不理解isArray,再次处于IE8模式。 原型扩展再次拯救。 现在它回来说一些类似于SyntaxError的内容:'in'的操作数无效:期望的对象

我实际上并不知道可能是什么但无论如何我不能动态地添加adhoc原型扩展,希望事情最终能够解决。 要么LESS不能用于IE,要么其他人可以指出我需要的所有修复才能使它工作。


I am playing aorund with using LESS along with respond.js to streamline the development of a new site. Both LESS and respond are quite simply neat. However, with LESS in IE I have run into many problems.

For starters in IE8 mode my IE10 reported that id did not understand "map". No problems, I wrote up an Array.prototype map extension. Then it said that it did not understand isArray, once again in IE8 mode. Prototype extensions to the rescue again. Now it comes back saying something along the lines of SyntaxError: Invalid operand to 'in': Object expected

I am not in fact aware of what in might be but in any case I cannot keep adding adhoc prototype extenions on the fly in the hope that things will eventually settle down. Either LESS is unusable with IE or else someone here can point me to all the fixes needed to make it work.


原文:https://stackoverflow.com/questions/18782273
更新时间:2023-04-19 08:04

最满意答案

你总是希望在特征中使用deflazy val (而不是val )来避免你发现的尴尬行为。

至于为什么会在JVM中得到Scala实现的低级细节,请查看Josh Suereth 2012年Scala Days的优秀演讲“Binary Resilience”


You always want to use either def or lazy val in traits (rather than just val) to avoid the awkward behavior you discovered.

As for why, which gets to the low-level details of Scala's implementation in the JVM, check out Josh Suereth's excellent talk "Binary Resilience" from Scala Days 2012.

相关问答

更多
  • 这是一个报告错误 - 你可以在这里投票: https : //youtrack.jetbrains.com/issue/PY-16132 It's a reported bug - you can vote for it here: https://youtrack.jetbrains.com/issue/PY-16132
  • 现在,编辑后,我想我明白你在追求什么。 但是你不能做你想要的,因为类型签名不匹配。 def x: Int = 5 val x: Int = 5 在这两种情况下,您都不提供任何东西并返回Int(在本例中为5)。 大! def expensive(p: Int => Boolean): List[Int] 现在你提供一些东西。 但val只是某处存储的对象。 您可以向标签引用的对象提供某些内容,但这与向标签“x”提供内容不同。 如果你想要val覆盖它,那么你需要使用def: def expensive: (I ...
  • def可以由def , val , lazy val或object的任何一个来实现。 所以这是定义成员的最抽象的形式。 由于traits通常是抽象的接口,说你想要一个val是说实现应该怎么做。 如果你要求一个val ,一个实现类不能使用def 。 仅当需要稳定的标识符(例如,依赖于路径的类型)时才需要val 。 这是你通常不需要的东西。 比较: trait Foo { def bar: Int } object F1 extends Foo { def bar = util.Random.nextInt( ...
  • 你总是希望在特征中使用def或lazy val (而不是val )来避免你发现的尴尬行为。 至于为什么会在JVM中得到Scala实现的低级细节,请查看Josh Suereth 2012年Scala Days的优秀演讲“Binary Resilience” 。 You always want to use either def or lazy val in traits (rather than just val) to avoid the awkward behavior you discovered. A ...
  • 以下是代码在初始化MainFoo时尝试执行的MainFoo : 分配一块内存,为val calcNumbers和val numbers提供足够的空间,最初设置为0 。 运行基类Foo的初始化程序,它在初始化calcNumbers时尝试调用numbers.map 。 运行子类MainFoo初始numbers MainFoo ,将numbers初始化为List(1, 2, 3) 。 由于在尝试在val calcNumbers = ...访问numbers尚未初始化numbers ,因此会出现NullPointe ...
  • 只需为M创建一个伴随对象,它定义静态值,然后在case类中引用它 object M { val description = "I'm M" } case class M extends A with B { override def description = M.description } 或假设子类型之间的共性 trait Description { val title: String val description = s"I'm ${title}" } object M exten ...
  • 因为def声明了一个方法,它由编译器放在类中,所以它一经编译就存在。 为了返回一些东西,一个方法必须运行到它实际返回的东西,所以你的第二个例子没有问题。 val声明一个“不可变值”,虽然它仍然必须初始化,在此之前它保持其类型的默认值 - 在这种情况下,0。这个初始化发生在trait T的构造函数运行之后,除非你改变你的使用早期初始化的示例: val y = new { val x = 42L } with T Because def declares a method, which is put in t ...
  • 当你第一次遇到它时,这会令人困惑,但这是预期的行为。 正常的初始化顺序是首先初始化超级特征中的val。 在您的示例中,这意味着特征A中的val x在匿名子类中的val data之前被初始化,因此导致NullPointer。 如果你想让你的例子工作,你必须使用一个名为“早期定义”的功能(语言规范中的5.1.6)。 在您的具体示例中,这是您需要使用的语法: val a = new { val data = new Object { val x = 42 } } with A 这在初始化A中的val之前 ...
  • 哈! 在通勤之家看出来:-)。 Scala允许具体类中的val覆盖特征中的def 。 我的特质变成了: trait LabelMethods { def setText(text: String) //... } trait MainView { def someLabel: LabelMethods // Note that this member becomes // a def in this trait... ...
  • 你要问的表达方式之间没有显着差异。 val x招致私人领域。 请注意,与vs.map(x => f(x))相比, vs.map(_+10)联函数。 但是你必须在任何情况下创建一个函数对象。 一个名字参数=> X是一个() => X引擎盖下。 从REPL中,使用javap显示代码。 -c代码, -v代表详细。 scala> vs.map(f) res0: List[Int] = List(2, 3, 4, 5, 6, 7, 8, 9, 10, 11) scala> :javap -pv - [snip] ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。