本文介绍了JSSOR - 无法读取未定义的类型属性“currentStyle"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的页面中实现 Jssor 滑块,但我一直在标题中出现该错误.

I'm trying to implement the Jssor slider into my page, but I keep coming up with that error in the title.

我的内容是通过 Javascript 动态创建的,如下所示:

My content is being dynamically created via Javascript, like so:

var slide = app.createHTML('div', "", {'id':'inventorySlides'}, null);

var div = document.getElementById('invDiv');
div.appendChild(slide);

然后我以相同的方式在程序上生成单元格 div 并将它们附加到 slide.

and then I procedurally generate cell divs in the same way and append them to slide.

我已经在我的主控制器中定义了一个函数,如基本用法页面上的示例(http://www.jssor.com/development/basic-usage-no-jquery.html),在所有的内容都生成并追加后,我调用函数

I've defined a function in my main controller as in the example on the basic usage page (http://www.jssor.com/development/basic-usage-no-jquery.html), and after all the content has been generated and appended, I call the function

jssor_slider1_starter('inventorySlides');

但后来我在控制台中收到错误消息.我试过记录inventorySlides div,它肯定存在于DOM 中,所以我知道不是那样.我尝试搜索 currentStyles,结果只在 IE 和 Opera 上,我使用的是 Chrome.

But then I get the error message in the console. I've tried logging the inventorySlides div, and it definitely exists in the DOM, so I know it's not that. I tried searching for currentStyles, which turns out is just on IE and Opera, and I'm using Chrome.

是不是我做错了什么?还是 Jssor 行为不端?

So is it something I'm doing wrong? Or is it Jssor that's misbehaving?

推荐答案

所以首先,我忘记包含 jssor.core.js 和 jssor.utils.js,虽然这并没有完全解决我的问题.

So firstly, I had forgotten to include jssor.core.js and jssor.utils.js, though that did not fully solve my problem.

解决方案是我需要创建一个带有属性 u="slides" 的 div,它位于 'inventorySlides' div 内,并且单元格嵌套在这个新 div 内

The Solution was that I needed to create a div with an attribute u="slides", which goes inside the 'inventorySlides' div, and the cells are nested inside this new div

注意:我回答这个问题的时间比被问到的时间要晚得多,因为当时我没有足够的声誉来回答我自己的问题,现在我无法再访问这个问题所引用的代码,所以我真的不能在答案中添加比评论中已经讨论的更多的细节.如果您需要此答案未提供的任何详细信息,我深表歉意,但在这一点上我无能为力.干杯 - 丹

NOTE: I made this answer much later than when it was asked because at the time I did not have enough reputation to be able to answer my own question, and now I no longer have access to the code this question is referencing, so I can't really add much more detail to the answer than what had already been discussed in the comments. I apologize if there's any details you need that this answer does not provide, but I can't help much past this point. Cheers - Dan

这篇关于JSSOR - 无法读取未定义的类型属性“currentStyle"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-28 19:28