简体   繁体   English

如何将插件添加到Bootstrap

[英]How to add plugins to Bootstrap

I found this really cool plugin for Bootstrap that measures password strength. 我发现这个非常酷的Bootstrap 插件可以测量密码强度。 It looks good, and I want to use it, but I can't figure out how to make it work. 它看起来很好,我想使用它,但我无法弄清楚如何使它工作。 According to the Github page, all you have to do to use it is "Just invoke the plugin on the password fields you want to attach a strength meter to.". 根据Github页面,你要做的就是“只需要在你想要附加强度计的密码字段上调用插件。”。 Unfortunately, they don't tell you where to put the files, nor which javascript files you actually need to use. 不幸的是,他们没有告诉你把文件放在哪里,也不告诉你实际需要使用哪些javascript文件。

I've been Googling every possible iteration of ways to add or install plugins for Bootstrap, and have come up empty each time. 我一直在谷歌搜索为Bootstrap添加或安装插件的每种可能的迭代方法,并且每次都是空的。 Does anyone have an answer here? 有人在这里有答案吗?

I guess the github pages can be confusing with all those source files. 我猜github页面可能会混淆所有这些源文件。 All you need to do is get the latest minified file from this page: 您需要做的就是从此页面获取最新的缩小文件:

https://github.com/ablanco/jquery.pwstrength.bootstrap/tree/master/dist https://github.com/ablanco/jquery.pwstrength.bootstrap/tree/master/dist

Download it, upload it, and load it into your HTML somewhere after your original bootstrap javascript file using 在原始引导程序javascript文件使用后,下载,上传并将其加载到HTML中

<script type="text/javascript" src="file/location/pwstrength-bootstrap-1.2.3.min.js"></script>

When you've done that, add the following javascript code to invoke the plugin on a class or element: 完成后,添加以下javascript代码以调用类或元素上的插件:

$(document).ready(function(){
    $(':password').pwstrength();
});

Just include the plugin css and javascripts after defining bootstrap in head of your html page. 在html页面的头部定义bootstrap之后,只需包含插件css和javascripts。

something like this: 这样的事情:

   <!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>

<script src="your plugin source"></script>

要添加到以前的解决方案:还要确保在html中包含jquery ,因为它是bootstrap的js所必需的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM