requirejs加载css

来源:互联网 发布:路由器域名重定向设置 编辑:程序博客网 时间:2024/04/30 05:16


 https://github.com/guybedford/require-css 下载到require-css包


html

<!DOCTYPE html><html><head><meta charset="utf-8" /><meta name="viewport"content="width=device-width, initial-scale=1, user-scalable=no" /><meta name="manifest" content="version.json" /><meta content="email=no" name="format-detection" /><meta content="telephone=no" name="format-detection" /><title></title></head><body><div class="alert alert-warning alert-dismissible fade in" role="alert"><button type="button" class="close" data-dismiss="alert"aria-label="Close"><span aria-hidden="true">×</span></button><strong>Holy guacamole!</strong> Best check yo self, you're notlooking too good.</div><script data-main="js/config.js"src="assets/lib/require/require.min.js" type="text/javascript"></script></body></html>


config.js

require.config({    baseUrl: 'js',    map: {        '*': {            'css': 'require/css'        }    },    paths: {        jquery: 'jquery',        bootstrap: 'bootstrap/bootstrap.min',        'bootstrap-table': 'bootstrap-table'    },    shim: {        bootstrap: {            deps: ['jquery', 'css!../css/bootstrap.min'],        },        'bootstrap-table': {           deps:['jquery', 'css!../css/bootstrap-table'],           exports: 'bootstrap-table'        }    },    waitSeconds: 50});requirejs(['jquery', 'bootstrap'], function ($, bootstrap) {  });

访问html页面即可查看

0 0