仅包含Bootstrap单个文件时,下拉菜单不起作用

时间:2019-06-09 15:57:53

标签: javascript twitter-bootstrap bootstrap-4

我只想为navbar包括Bootstrap JS文件,不需要轮播和其他脚本。

这是我的Gulp串联JS文件的任务,如您所见,我包括collapse, dropdown and util个文件和我的文件。 当我尝试单击navbar-toggler时,下拉菜单不显示,并且在控制台中出现此错误

Uncaught TypeError: Cannot read property 'getSelectorFromElement' of undefined

在过去的一年中,直到今天我做npm update时,这种方法都行得通,现在我不确定是什么问题? 如果我删除了这3个文件,并且仅包含bootstrap.bundle(例如,它已被注释掉),则navbar可以正常工作。我怎样才能解决这个问题?

const nodeFolder = './node_modules/';
const jsFolder = './assets/js/';

gulp.task('js', function () {

     const jsFiles = [
          nodeFolder + '/popper.js/dist/umd/popper.min.js',

          //nodeFolder + '/bootstrap/js/dist/alert.js',
          //nodeFolder + '/bootstrap/js/dist/button.js',
          //nodeFolder + '/bootstrap/js/dist/carousel.js',
          nodeFolder + '/bootstrap/js/dist/collapse.js',
          nodeFolder + '/bootstrap/js/dist/dropdown.js',
          //nodeFolder + '/bootstrap/js/dist/index.js',
          //nodeFolder + '/bootstrap/js/dist/modal.js',
          //nodeFolder + '/bootstrap/js/dist/popover.js',
          //nodeFolder + '/bootstrap/js/dist/scrollspy.js',
          //nodeFolder + '/bootstrap/js/dist/tab.js',
          //nodeFolder + '/bootstrap/js/dist/toast.js',
          //nodeFolder + '/bootstrap/js/dist/tooltip.js',
          //nodeFolder + '/bootstrap/js/dist/scrollspy.js',
          nodeFolder + '/bootstrap/js/dist/util.js', 
          //nodeFolder + '/bootstrap/dist/js/bootstrap.bundle.min.js',

          jsFolder + '/main.js',
     ];

     return gulp.src(jsFiles)
          .pipe(prettyError())
          .pipe(plumber({ errorHandler: onError }))
          .pipe(concat('all.min.js'))
          .pipe(uglify({
               compress: true
          }))
          .pipe(gulp.dest('./assets/js/'))
          .pipe(notify({ message: 'JS completed!', onLast: true }));

});

0 个答案:

没有答案