私はこの奇妙な問題を抱えています: ページが読み込まれない IE11 を除くすべての主要なブラウザーで正常に動作するページがあります。
IE 11 でコンソールをチェックインしたところ、次のエラーが見つかりました。
エラーは、スクロール バーのスタイルを設定する関数 SetStyle を参照しています。
class ScrollBarStyle{
init(){
return{
setStyle: this._setStyle
}
}
_setStyle(node,color,targetClass){
let self = this;
let children = Array.from(node.children); // I have set Array.from polifyll for ie11
if(children){
children.forEach(function(el){
if(el.classList.contains(targetClass)){
el.style.width = '10px';
el.style.background = color;
el.style.opacity = '1'
return
}
self.setStyle(el,color,targetClass)
})
}
}
}
これは、スクロールバーのスタイルを次のように設定するために使用する関数です。
_initMainScrollBar(){
let self = this;
this.contents.forEach(function(cnt){
let ps = self.createScrollBar(cnt); //using perfect scrollbar plugin
let color = self._RetrieveScrollBarColor(cnt)[0]; // get the main color of a section
self.scrollBarStyle.setStyle(cnt,color,self.targetClass) //set the style
})
}
何が問題なのかわかりません。このコードは他のブラウザでも機能しますが、ie11 とthis
キーワードに関する有用な情報は見つかりませんでした。
どうやらvar n=this
n を実行すると未定義になるようです。
正直なところ、何が問題なのか見当がつきません。
私はgulpでbabelを使用しています:
gulp.task('js',()=>{
return browserify({
entries: ['./src/js/main.js'],
debug:true
})
.bundle()
.pipe(source('bundle.js'))
.pipe(buffer())
.pipe(babel({
presets: ['env'],
compact: true
}))
.pipe(uglify())
.pipe(gulp.dest('./src/dist/js/'))
.pipe(browserSync.stream());
});
また、Array.from
ie11のポリフィルを挿入したので、問題はないと思います
誰かがこの問題についてのヒントを教えてくれますか? たぶん、パーフェクトスクロールバープラグインに関連するものですか?