


Detailed explanation of Grunt plug-in LiveReload to realize automatic page refresh (two options), gruntlivereload
Option 1: grunt-livereload Chrome Plug-in
Advantages: Installation and configuration are simple and convenient.
Disadvantages: Need to cooperate with specified browser plug-ins (Firefox also has related plug-ins, IE you know).
1. 2 plug-ins need to be installed: grunt-contrib-watch, connect-livereload
Execute command:
Copy code The code is as follows:
npm install --save-dev grunt-contrib-watch connect-livereload
2. Install browser plug-in: Chrome LiveReload
3. Configure a web server (IIS/Apache), LiveReload needs to run in the local server environment (support for file:/// file path is not very good).
4. Modify the Gruntfile.js file:
module.exports = function(grunt) { // 项目配置(任务配置) grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), watch: { client: { files: ['*.html', 'css/*', 'js/*', 'images/**/*'], options: { livereload: true } } } }); // 加载插件 grunt.loadNpmTasks('grunt-contrib-watch'); // 自定义任务 grunt.registerTask('live', ['watch']); };
5. Execution: grunt live
When you see the following prompt, it means that the monitoring task has started:
Copy code The code is as follows:
Running "watch" task
Waiting...
6. Open our page, for example: http://localhost/
7. Click the ICON of the Chrome LiveReload plug-in again. At this time, the small dot in the center of the ICON circle becomes solid, indicating that the plug-in is executed successfully. At this time, you can change the website files and see if they are updated in real time?
Option 2: grunt-contrib-watch grunt-contrib-connect grunt-livereload
Advantages: Automatically build a static file server, no need to build a Web server on your own computer.
Does not require browser plug-in support (not currently limited to a specific browser).
There is no need to manually add livereload.js to the web page.
Disadvantages: For those who are new to it, the configuration is slightly complicated.
1. Install the 3 plug-ins we need: grunt-contrib-watch, grunt-contrib-connect, connect-livereload
Execute command:
Copy code The code is as follows:
npm install --save-dev grunt-contrib-watch grunt-contrib-connect connect-livereload
2. Modify the Gruntfile.js file:
module.exports = function(grunt) { // LiveReload的默认端口号,你也可以改成你想要的端口号 var lrPort = 35729; // 使用connect-livereload模块,生成一个与LiveReload脚本 // <script src="http://127.0.0.1:35729/livereload.js?snipver=1" type="text/javascript"></script> var lrSnippet = require('connect-livereload')({ port: lrPort }); // 使用 middleware(中间件),就必须关闭 LiveReload 的浏览器插件 var lrMiddleware = function(connect, options) { return [ // 把脚本,注入到静态文件中 lrSnippet, // 静态文件服务器的路径 connect.static(options.base[0]), // 启用目录浏览(相当于IIS中的目录浏览) connect.directory(options.base[0]) ]; }; // 项目配置(任务配置) grunt.initConfig({ // 读取我们的项目配置并存储到pkg属性中 pkg: grunt.file.readJSON('package.json'), // 通过connect任务,创建一个静态服务器 connect: { options: { // 服务器端口号 port: 8000, // 服务器地址(可以使用主机名localhost,也能使用IP) hostname: 'localhost', // 物理路径(默认为. 即根目录) 注:使用'.'或'..'为路径的时,可能会返回403 Forbidden. 此时将该值改为相对路径 如:/grunt/reloard。 base: '.' }, livereload: { options: { // 通过LiveReload脚本,让页面重新加载。 middleware: lrMiddleware } } }, // 通过watch任务,来监听文件是否有更改 watch: { client: { // 我们不需要配置额外的任务,watch任务已经内建LiveReload浏览器刷新的代码片段。 options: { livereload: lrPort }, // '**' 表示包含所有的子目录 // '*' 表示包含所有的文件 files: ['*.html', 'css/*', 'js/*', 'images/**/*'] } } }); // grunt.initConfig配置完毕 // 加载插件 grunt.loadNpmTasks('grunt-contrib-connect'); grunt.loadNpmTasks('grunt-contrib-watch'); // 自定义任务 grunt.registerTask('live', ['connect', 'watch']); };
5. Execution: grunt live
See the following prompt, indicating that the web server has been set up and the monitoring task has started:
Copy code The code is as follows:
Running "connect:livereload" (connect) task
Started connect web server on 127.0.0.1:8000.
Running "watch" task
Waiting...
Note: Before executing this command, if you have installed the LiveReload browser plug-in, it must be closed.
6. Open our page, for example: http://localhost:8000/ or http://127.0.0.1: 8000/
Note: The local server address opened here is the static file server address we just built through connect, instead of the Web server address you used to build your own using IIS or Apache.
The above is a detailed explanation of the Grunt plug-in LiveReload to realize automatic page refresh (two options) in this article. I hope you like it.

使用Python和WebDriver实现网页自动刷新引言:在日常的网页浏览中,我们常常会遇到需要频繁刷新网页的场景,比如监控实时数据、自动刷新动态页面等。手动刷新网页会浪费大量的时间和精力,因此我们可以使用Python和WebDriver来实现自动刷新网页的功能,提高我们的工作效率。一、安装和配置环境在开始之前,我们需要安装和配置相应的环境。安装Python

设置网页的自动刷新可以使用HTML的“meta”标签、JavaScript的“setTimeout”函数、“setInterval”函数或HTTP的”Refresh“头。详细介绍:1、使用HTML的“meta”标签,在HTML文档的“<head>”标签中,可以使用“meta”标签来设置网页的自动刷新;2、JavaScript的“setTimeout”函数等等。

win11桌面经常自动刷新怎么办?win11系统是微软推出的最新Windows系统,拥有最新的技术构建,能够提供给你最新的优质服务,但同时,也存在着一些新型的问题。最近有小伙伴反应,win11在更新之后就经常出现桌面不断刷新的现象,这很有可能是因为系统出现了一些问题,那么,我们究竟该怎么解决这个问题呢?下面就由小编为大家带来win11桌面经常自动刷新解决方法。win11桌面经常自动刷新解决方法方法一:卸载更新1、首先我们使用键盘“ctrl+shift+esc”组合键打开任务管理器。2、打开后点击

Python实现无头浏览器采集应用的页面自动刷新与定时任务功能解析随着网络的快速发展和应用的普及,网页数据的采集变得越来越重要。而无头浏览器则是采集网页数据的有效工具之一。本文将介绍如何使用Python实现无头浏览器的页面自动刷新和定时任务功能。无头浏览器采用的是无图形界面的浏览器操作模式,能够以自动化的方式模拟人类的操作行为,从而实现访问网页、点击按钮、填

虽然Win11系统已经推出很长一段时间了,但我们在使用的过程中还是会遇到很多问题,例如有的小伙伴们在使用过程中经常会遇到屏幕桌面一直自动刷新的情况,这时候要如何解决呢?下面就和小编一起来看看解决方法吧。Win11桌面自动刷新的解决方法1、首先我们使用键盘“ctrl+shift+esc”组合键打开任务管理器。2、打开后点击左上角的“文件”,并选择其中的“运行新任务”。3、然后勾选“以系统管理权限创建此任务”选项,

Win10系统桌面经常自动刷新怎么解决?我们日常中都会使用电脑来学习娱乐,桌面上也放了很多我们需要的文件和应用,但是近期有小伙伴在使用win10的时候,桌面一直不断的自动刷新。如果你不会解决的话,小编下面整理了Win10系统桌面经常自动刷新解决指南,感兴趣的话,跟着小编一起往下看看吧!Win10系统桌面经常自动刷新解决指南1、鼠标右键点击“开始“菜单,选择“任务管理器”,如图所示。2、在”任务管理器“界面,在进程中找到”Windows资源管理器“,如图所示。3、鼠标右键点击它,在出现的界面中选择

Python和Excel是两个强大的工具,结合起来可以开启自动化世界。Python具有多功能的库和用户友好的语法,使我们能够编写脚本来有效地执行各种任务。另一方面,Excel是一种广泛使用的电子表格程序,它为数据分析和操作提供了熟悉的界面。在本教程中,我们将探索如何利用Python来自动化刷新Excel电子表格的过程,从而节省我们的时间和精力。您是否发现自己花费了宝贵的时间使用更新的数据手动刷新Excel电子表格?这是一项重复且耗时的任务,可能会真正降低生产力。在本文中,我们将指导您完成使用Py

火狐浏览器app非常多手机用户都在用,搜索功能非常强大,只要是你想知道的想看的,都能第一时间找到结果和答案,所有浏览板块都是开放的,享受最舒适的上网浏览服务。自动屏蔽烦人的广告弹窗,首页搜索栏非常干净简洁,而且只需要输入关键词,就能找到相对应的结果,不同格式的文件文档都可以下载缓存,新闻资讯、视频内容都是免费翻阅观看的,还能设置自动刷新,解放双手上网速度更快,且没有任何卡顿,记录数据自动保存不会丢失,现在小编仔细一一为火狐浏览器用户们带来设置自动刷新的操作步骤。 1、首先打开火狐浏览器


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Mac version
God-level code editing software (SublimeText3)

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
