zoukankan      html  css  js  c++  java
  • 使用grunt实现浏览器自动刷新

      首先安装必备的插件:

    • nodejs安装
    • grunt安装
    • grunt-contrib-watch:npm install grunt-contrib-watch —save-dev

    因为这是要引入livereload来监听你对文件所做的修改,所以需要一个服务器来实现浏览器与服务期间的通信,

    因此,可以利用apache实现。将你的项目放在Apache服务器下。

      然后就是进行基本的配置了:

    grunt.initConfig(

    watch: {

    livereload: {

    options: {livereload: true},

    files: ['dev/test.js', 'index.html']

    }

    })

    grunt.loadNpmTasks('grunt-contrib-watch');

    要实时刷新的界面中引入一段脚本<script src="//localhost:35729/livereload.js"></script>

      最后就是使用grunt启动你的监听,大功就告成啦!!!

     

  • 相关阅读:
    第九周
    第八周
    第七周
    代码复审核查表
    对软件开发的理解
    第六周
    网站流量分析架构及实现
    hive的sql语句
    精简客户端搭建Oracle数据库
    idaa搭建maven发布tomcat
  • 原文地址:https://www.cnblogs.com/lds2014/p/3934531.html
Copyright © 2011-2022 走看看