我正在使用带有Json的Cycle2滑块。滑块工作正常,但我在谷歌浏览器中收到此错误:未捕获的TypeError:无法读取属性'标题'未定义的。
这是一个正在运作的Codepen:http://codepen.io/anon/pen/ojavEW
谷歌浏览器突出显示了这部分代码:
i.title.$t, l = 0; l < i.link.length; l++)
我不知道如何修复它,有什么建议吗?
.cycle-slideshow .item {
width: 100%;
height: 400px;
padding: 0!important;
margin: 4px!important;
overflow: hidden;
}
.cycle-slideshow {
margin: auto;
width: 100%;
height: 400px;
}
.cycle-slideshow img {
width: 100%;
height: auto;
max-width: 450px;
}
.slider-overlay {
position: relative;
height: 100%;
word-wrap: break-word;
display: none;
}
.cycle-slideshow .item:hover .slider-overlay {
display: block;
}
.slider-centered {
position: absolute;
display: table;
table-layout: fixed;
vertical-align: middle;
word-wrap: break-word;
height: 100%;
}
.slide-content {
display: table-cell;
vertical-align: middle;
word-wrap: break-word;
text-overflow: ellipsis;
overflow: hidden;
padding: 0 5px;
color: #fff;
text-align: center;
}
.slide-content h3,
.slider-sum {
word-wrap: break-word;
}
.slider-sum {
margin: 10px 0;
word-wrap: break-word;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
.slide-content h3 {
letter-spacing: 3px;
text-transform: uppercase;
font: normal normal 30px Oswald;
word-wrap: break-word;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
&#13;
<script src="http://malsup.github.io/jquery.cycle2.carousel.js"></script>
<script src="http://malsup.github.com/jquery.cycle2.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script style='text/javascript'>
//<![CDATA[
function showgalleryposts(t) {
var e = t.feed.openSearch$totalResults.$t,
n = new Array;
for (var r = 0; e > r; ++r) n[r] = r;
for (1 == random_posts && n.sort(function() {
return .5 - Math.random()
}), numposts_gal > e && (numposts_gal = e), r = 0; numposts_gal > r; ++r) {
for (var i = t.feed.entry[n[r]], o = i.title.$t, l = 0; l < i.link.length; l++)
if ("alternate" == i.link[l].rel) {
posturl_gal = i.link[l].href;
break
}
if (
"content" in i) var u = i.content.$t;
if (s = u, a = s.indexOf("<img"), b = s.indexOf('src="', a), c = s.indexOf('"', b + 5), d = s.substr(b + 5, c - b - 5), -1 != a && -1 != b && -1 != c && "" != d) var m = d;
else var m = "";
document.write('<div class="item" style="background: url(' + m + ');"><div class="slider-overlay"><div class="slider-centered"><span class="slide-content"><h3 style="margin:10px 0 0;">'), document.write(o + "</h3>");
var g = /<\S[^>]*>/g;
if (u = u.replace(g, ""), 1 == showpostsummary_gal)
if (u.length < numchars_gal) document.write(u), document.write("</span>");
else {
u = u.substring(0, numchars_gal);
var p = u.lastIndexOf(" ");
u = u.substring(0, p), document.write("<span class='slider-sum'>" + u + "...</span>"), document.write(
"<span class='slide-more'><a href='" + posturl_gal + "'>Read More</a></span></span></div>")
}
document.write('</div>'), document.write("</div>")
}
}
var showpostthumbnails_gal = !0,
showpostsummary_gal = !0,
random_posts = !1,
numchars_gal = 30,
numposts_gal = 10;
//]]>
</script>
<div class='cycle-slideshow' data-cycle-fx=carousel data-cycle-timeout=1000 data-cycle-carousel-visible=3 data-cycle-carousel-fluid=true data-cycle-pause-on-hover=true data-cycle-slides='.item'>
<script src='http://www.thebeautybybel.com/feeds/posts/default?orderby=published&alt=json-in-script&callback=showgalleryposts&max-results=6'></script>
</div>
&#13;