初次使用bootstrap记录心得

因为项目需要,原本项目用的前端框架为easyui,现重构为bootstrap,主要是记录一下使用方法.
先在一个界面引用bootsrap相关js文件,以便测试
在这里插入图片描述引用相关标签(已有)
在这里插入图片描述引用的相关js (已有)
在这里插入图片描述在单独的页面上引用bootstrap 相关js/css(注意:bootstrap是分组件的,需要引用不同的js组件来实现不同的功能)

<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/tag.inc.jsp"%>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
<title>My JSP 'weightWay.jsp' starting page</title>
<link rel="stylesheet" href="<c:url value='/mesui/bootstrap/css/bootstrap.min.css'/>" type="text/css"></script>
<link rel="stylesheet" href="<c:url value='/mesui/bootstrap/css/bootstrap-switch.min.css'/>" type="text/css"></script>
<script type="text/javascript" src="<c:url value='/mesui/bootstrap/js/bootstrap.min.js'/>"></script>
<script type="text/javascript" src="<c:url value='/mesui/bootstrap/js/bootstrap-table.js'/>"></script>
<script type="text/javascript" src="<c:url value='/mesui/bootstrap/js/bootstrap-switch.min.js'/>"></script>
<script type="text/javascript">
    	$(function(){
    		searchdata();
    		/* $('#my-checkbox').bootstrapSwitch('state',true);
    		$('[name="my-checkbox"]').bootstrapSwitch({
						onText:"开启",
						offText:"关闭",
						onColor:"success",
						offColor:"danger",
						size:"small",
						onInit:function(element,event,state){//控件初始化时触发  
				            console.log('onInit:');  
				            console.log(this);//开关控件的jQuery对象  
				            console.log(element);//checkbox的DOM elememt元素  
				            console.log(event);//jQuery事件  
				            console.log(state);//开关的初始化选中状态  
        				},
						onSwitchChange:function(event,state){
							var step = this.value;
							if(state==true){
								console.log('已打开'+step);
							}else{
								console.log('已关闭'+step);
							}
						}
					}); */
				//	$('[name="my-checkbox1"]').bootstrapSwitch();  
				//	$('[name="my-checkbox2"]').bootstrapSwitch();  
    	});
    	function searchdata(){
    		$('#weightWay').bootstrapTable({
    			method: 'post',
        		editable:true,//开启编辑模式  
        		clickToSelect: true,
        		cache : false,
    			url:"<c:url value='/qm/weightWay.sp?method=list'/>",
    			columns:[
    				{field:'step_number',title:'工序',align:'center',formatter:function(val,row,index){
    					var a = row.step_number;
    					if(a=='20'){
    						return '挤出';
    					}
    					if(a=='30'){
    						return '辐照';
    					}
    					if(a=='40'){
    						return '扩张';
    					}
    					if(a=='50'){
    						return '上盘';
    					}
    					if(a=='60'){
    						return '切管';
    					}
    					if(a=='90'){
    						return '封帽';
    					}
    				}},
    				{field:'is_feed',title:'投料称重功能',align:'center',formatter: forIsFeed},//
    				{field:'is_remove',title:'卸盘/筐称重功能',align:'center',formatter: forIsRemove},//
    				{field:'is_kg',title:'单位',align:'center'},
    			],
    			onLoadSuccess:function(){
    					//$('#my-checkbox1').bootstrapSwitch('state',true);
						$('[name="my-checkbox1"]').bootstrapSwitch({
						onText:"开启",
						offText:"关闭",
						onColor:"success",
						offColor:"danger",
						size:"small",
						onInit:function(element,event,state){//控件初始化时触发 
							console.log('onInit:');  
				            console.log(this);//开关控件的jQuery对象  
				            console.log(element);//checkbox的DOM elememt元素  
				            console.log(event);//jQuery事件  
				            console.log(state);//开关的初始化选中状态  
						},
						onSwitchChange:function(event,state){
							var step = this.value;
							if(state==true){
								console.log('已打开'+step);
							}else{
								console.log('已关闭'+step);
							}
						}
					});
					$('[name="my-checkbox2"]').bootstrapSwitch({
						onText:"开启",
						offText:"关闭",
						onColor:"success",
						offColor:"danger",
						size:"small",
						onInit:function(element,event,state){//控件初始化时触发 
							console.log('onInit:');  
				            console.log(this);//开关控件的jQuery对象  
				            console.log(element);//checkbox的DOM elememt元素  
				            console.log(event);//jQuery事件  
				            console.log(state);//开关的初始化选中状态  
						},
						onSwitchChange:function(event,state){
							var step = this.value;
							if(state==true){
								console.log('已打开'+step);
							}else{
								console.log('已关闭'+step);
							}
						}
					})
				}, 
    			queryParams:{
    			},
    		})
    	}
    	function forIsFeed(val,row,index){
    		var a=row.key;
    		if(0==val){
    			return '-';
    		}else{
    			if(1==val){
    				$('[name="my-checkboxs1"]').bootstrapSwitch('state',true);
    			}
    			if(2==val){
    				$('[name="my-checkboxs1"]').bootstrapSwitch('state',false);
    			}
    			return "<input value='"+a+"' type='checkbox' name='my-checkbox1'/>";
    		}
    	}
    	
    	function forIsRemove(val,row,index){
    		var a=row.key;
    		if(0==val){
    			return '-';
    		} else{
    			if(1==val){
    				$('#my-checkboxs2').bootstrapSwitch('state',true);
    			}
    			if(2==val){
    				$('#my-checkboxs2').bootstrapSwitch('state',false);
    			}
    			return "<input value='"+a+"' type='checkbox' name='my-checkbox2' />";
    		}
    	}
    		
    </script>

  </head>
  	
  	<!-- <input type='checkbox' name='my-checkbox' id='my-checkbox'> -->
  <body>
    	<div>
    		<table id="weightWay" 
    		class="table table-striped table-bordered table-hover table-condensed" style="width: 60%;"> </table>
    	</div>
  </body>
</html>

测试用的页面

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小板凳-BGM

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值