Browsersync不会重新加载所有页面 [英] Browsersync not reloading all pages

查看:135
本文介绍了Browsersync不会重新加载所有页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我浏览过他们的浏览器但我有他们所说的一切,但它只刷新或同步index.hrml,但about.html例如不。



我的结构是这样的:

  -booming-gaes-web 
-dist
-node_modules
-src
-index .html
-about.html
-gulpfile.js

所以我的html文件直接在我的src文件夹中,并且gulp文件与src文件夹位于同一文件夹中。



我的大文件:

  //包含gulp 
var gulp = require('gulp');
//包含插件

var browserSync = require('browser-sync');


//观看文件以进行更改
gulp.task('watch',function(){
gulp.watch('src / js / *。js ',['js-watch']);
gulp.watch('src / css / *。scss',['sass-watch']);
gulp.watch('src / css /*.css',['prefix']);
gulp.watch('src / *。html')on('change',browserSync.reload);
browserSync({
文件:['src / index.html','about.html'],
服务器:{
baseDir:'src',
目录:true
}
});
});

任何想法我做错了什么?谢谢!

解决方案

我刚刚发现了...



我的about page does not have a body tag,browsersync need it have a body tag to be working。



从他们的帮助:


99%的时间,这是因为您的网页没有body标签。
为了使Browsersync正确连接,body标签必须在您的网站中存在
(我们在它后面添加一个脚本标签)。


Browsersync is just reloading index.html, even though I have my basedir set, and even the specific files listed on the files option.

I have looked on their docu but I have everything as they say, still it only refreshed or syncs index.hrml but about.html for example not.

My structure is this:

-booming-gaes-web
  -dist
  -node_modules
  -src
    -index.html
    -about.html
  -gulpfile.js

So my html files are direclty on my src folder, and the gulp file is in the same folder as the src folder.

My gulp file:

// Include gulp
var gulp = require('gulp');
// Include  Plugins

var browserSync   = require('browser-sync');


// Watch Files For Changes
gulp.task('watch', function() {
    gulp.watch('src/js/*.js', ['js-watch']);
    gulp.watch('src/css/*.scss', ['sass-watch']);
    gulp.watch('src/css/*.css', ['prefix']);
    gulp.watch('src/*.html').on('change', browserSync.reload);
    browserSync({
      files: ['src/index.html','about.html'],
      server:{
        baseDir:'src',
        directory: true
      }
    });
});

Any ideas what im I doing wrong ? thanks!

解决方案

I just found out...

My about page didnt had a body tag, browsersync needs it to have a body tag in order to work.

From their help:

99% of the time, it's because your web page doesn't have a body tag. In order for Browsersync to connect properly the body tag must be present in your website (we add a script tag just after it).

这篇关于Browsersync不会重新加载所有页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆