Javascript SC.ImageView在设置值时引发错误
设置子类SproutCore图像视图(Javascript SC.ImageView在设置值时引发错误,javascript,sproutcore,Javascript,Sproutcore,设置子类SproutCore图像视图(SC.ImageView)的值属性时,会引发运行时错误: 在Safari和Firefox中: TypeError:表达式“elem.setAttribute”[undefined]的结果不是函数。 在Chrome中: uncaughttypeerror:Object digdeer.ZoomLayerView:sc398没有方法“setAttribute” 以下代码(第4735行)的/static/sproutcore/foundation/en/curre
SC.ImageView
)的值
属性时,会引发运行时错误:
在Safari和Firefox中:TypeError:表达式“elem.setAttribute”[undefined]的结果不是函数。
在Chrome中:uncaughttypeerror:Object digdeer.ZoomLayerView:sc398没有方法“setAttribute”
以下代码(第4735行)的/static/sproutcore/foundation/en/current/javascript.js中出现错误:
图像已加载但未显示
我使用的是RubyGem中最新版本的sproutcore(看起来是1.4.5)
我如何解决这个问题
资料来源如下:
DigDeeper.ZoomTileView = SC.ImageView.extend({
// Properties
zoom: null,
layer: null,
scaleIndex: null,
column: null,
row: null,
// Overridden properties
classNames: [ 'zoom-tile-view' ],
// Computed properties
scale: function () {
return Math.pow( 2, this.get( 'scaleIndex' ) );
}.property( 'scaleIndex' ),
id: function () {
return "%@.%@.%@.%@".fmt(
DigDeeper.ZoomTileView.zeroPad( 0, 5 ),
DigDeeper.ZoomTileView.zeroPad( this.get( 'scale' ), 0 ),
DigDeeper.ZoomTileView.zeroPad( this.get( 'column' ), 0 ),
DigDeeper.ZoomTileView.zeroPad( this.get( 'row' ), 0 )
);
}.property('layer','scaleIndex','column','row').cacheable(),
value: function () {
return "/static/dig_deeper/en/current/resources/images/%@.png".fmt( this.get( 'id' ) );
}.property( 'id' ),
});
您的SC.ImageView设计是什么样子的?下面是一个示例,当处理一个很长的服务器调用时,我会弹出一个小进度微调器:
validateProgressImage: SC.ImageView.design({
layout: { top: 63, left: 150, height: 16, width: 16 },
value: sc_static("images/ajax-loader.gif"),
canLoadInBackground: true,
useCanvas: NO,
useImageQueue: NO,
isVisible: YES
}),
我的ajax-loader.gif文件位于我的resources/images目录中 值方法后面有一个逗号
删除它可能会解决您的问题。实际上,我正在对它进行子类化。也许这就是问题所在。我觉得这很可能。setAttribute
方法丢失是由于定义视图时出现语法错误而导致的一种错误。
validateProgressImage: SC.ImageView.design({
layout: { top: 63, left: 150, height: 16, width: 16 },
value: sc_static("images/ajax-loader.gif"),
canLoadInBackground: true,
useCanvas: NO,
useImageQueue: NO,
isVisible: YES
}),