【发布时间】:2015-07-07 18:09:33
【问题描述】:
我在 Chrome 开发人员工具中收到此错误,但我在页面上看不到任何错误。
这是 JS 的简短摘录:
function svgIcon( el, config, options ) {
this.el = el;
this.options = extend( {}, this.options );
extend( this.options, options );
this.svg = Snap( this.options.size.w, this.options.size.h );
this.svg.attr( 'viewBox', '0 0 64 64' );
this.el.appendChild( this.svg.node );
// state
this.toggled = false;
// click event (if mobile use touchstart)
this.clickevent = mobilecheck() ? 'touchstart' : 'click';
// icons configuration
this.config = config[ this.el.getAttribute( 'data-icon-name' ) ];
// reverse?
if( hasClass( this.el, 'si-icon-reverse' ) ) {
this.reverse = true;
}
if( !this.config ) return;
var self = this;
我相信这段代码说明不了太多,所以页面可以在这里找到:http://goo.gl/j7M5r8
我已经尝试通过查看 Stackoverflow 上的其他类似案例来解决问题,它指出要么缺少某些东西,要么有某些东西与读取/写入的顺序有关。
我还没有写 svgicons.js,所以应该不会有任何问题。但是我可以看到有些人和我有同样的问题,但没有提供对该问题的解释或答案。 Here is basically the same question from another person.
相关文件:
【问题讨论】:
-
与其去网站,我问一下,你怎么调用
svgIcon函数 -
感谢您的评论。你的意思是调用吗? Incase:
window.svgIcon = svgIcon;从我对 JS 的小知识来看,我不确定这是否是您所指的。对不起。
标签: javascript svg