m_Orchestrate learning system---三十一、模板和需求的关系
m_Orchestrate learning system---三十一、模板和需求的关系
一、总结
一句话总结:模板为了适应广大用户,有很多功能样式,但是,你需要的只是部分,所以删掉不需要的,如果有需要,需要的时候再加上
删 需
1、bootstrap-switch(checkbox)怎么让switch在on的状态下传递值1过去控制器?
switch value 1
只需要将switch的value设置为1即可
因为thinkphp里面的checkbox的机制是选中才传值过去,不选中是不会传值的
就算switch的值设置为1,不选中的时候还是没有办法传递值过去
2、树形结构的上下级选中的js代码?
checkbox-parent checkbox-child dataid
<script type="text/javascript">
/* 权限配置 */
$(function () {
//动态选择框,上下级选中状态变化
$('input.checkbox-parent').on('change', function () {
var dataid = $(this).attr("dataid");
$('input[dataid^=' + dataid + ']').prop('checked', $(this).is(':checked'));
});
$('input.checkbox-child').on('change', function () {
var dataid = $(this).attr("dataid");
dataid = dataid.substring(0, dataid.lastIndexOf("-"));
var parent = $('input[dataid=' + dataid + ']');
if ($(this).is(':checked')) {
parent.prop('checked', true);
//循环到顶级
while (dataid.lastIndexOf("-") != 2) {
dataid = dataid.substring(0, dataid.lastIndexOf("-"));
parent = $('input[dataid=' + dataid + ']');
parent.prop('checked', true);
}
} else {
//父级
if ($('input[dataid^=' + dataid + '-]:checked').length == 0) {
parent.prop('checked', false);
//循环到顶级
while (dataid.lastIndexOf("-") != 2) {
dataid = dataid.substring(0, dataid.lastIndexOf("-"));
parent = $('input[dataid=' + dataid + ']');
if ($('input[dataid^=' + dataid + '-]:checked').length == 0) {
parent.prop('checked', false);
}
}
}
}
});
});
</script>

3、Auth权限管理规则无限级分类权限组选择权限的树形结构操作中,获取祖先id代码?
静态数组
注意代码里面的静态数组已经清空静态数组的操作
算法操作的思路为:從孩子id開始,通過遞歸一直找到所有祖先,並且返回
算法应用的场景为:规则格式化函数中
//最後一個字段true的作用是為了清空下面的靜態數組
public static function getparentid($authRuleId){
$AuthRuleRes=db('auth_rule')->select();
return self::_getparentid($AuthRuleRes,$authRuleId,True);
} //從孩子id開始,通過遞歸一直找到所有祖先,並且返回
public static function _getparentid($AuthRuleRes,$authRuleId,$clear=False){
static $arr=array();
if($clear){
$arr=array();
}
foreach ($AuthRuleRes as $k => $v) {
if($v['aru_id'] == $authRuleId){
$arr[]=$v['aru_id'];
self::_getparentid($AuthRuleRes,$v['aru_pid'],False);
}
}
asort($arr);//父級編號始終比子集編號小
$arrStr=implode('-', $arr);
return $arrStr;//輸出結果為孩子id和祖先id,比如1-6
}
4、input标签内能否直接套用原生php(input标签<内能否套用<?php ?>)?
可以
<input name="rules[]" value="{$authRule.id}"
<?php $arr=explode(',', $authgroups['rules']); if(in_array($authRule['id'], $arr)){echo 'checked="checked"';} ?>
dataid="id-{$authRule.dataid}" class="inverted checkbox-parent {if condition="$authRule['level'] neq 0"} checkbox-child {/if} " type="checkbox">
5、如何判断一个数是否在数组中(php中函数)?
in_array()
<input name="rules[]" value="{$authRule.id}" <?php $arr=explode(',', $authgroups['rules']); if(in_array($authRule['id'], $arr)){echo 'checked="checked"';} ?> dataid="id-{$authRule.dataid}" class="inverted checkbox-parent {if condition="$authRule['level'] neq 0"} checkbox-child {/if} " type="checkbox">
6、php判断字段为空?
is_null empty isset
empty
如果 变量 是非空或非零的值,则 empty() 返回 FALSE。换句话说,””、0、”0″、NULL、FALSE、array()、var $var、未定义;以及没有任何属性的对象都将被认为是空的,如果 var 为空,则返回 TRUE。
- 如果e是未定义或值为NULLL,
e=NULL,它肯定是空,即empty($e)=true;
- 如果e是int类型,
e=0,就相对于数字,0代表为零,即empty($e)=true;
- 如果e是string类型,
e=”“,相对于字符串,”“就代表为是空,即empty($e)=true;
- 如果e是string类型,
e=”0”,相对于字符串,”0“就代表为是零,即empty($e)=true;
- 如果e是bool类型,
e=false,相对true,false就代表为空,即empty($e)=true;
- 如果e是array类型,
a=array(),相对数组来说,没有元素的数据就为空,即empty($e)=true;
isset
如果 变量 存在(非NULL)则返回 TRUE,否则返回 FALSE(包括未定义)。变量值设置为:null,返回也是false;unset一个变量后,变量被取消了。注意,isset对于NULL值变量,特殊处理。
is_null
检测传入值【值,变量,表达式】是否是null,只有一个变量定义了,且它的值是null,它才返回TRUE . 其它都返回 FALSE 【未定义变量传入后会出错!】
== VS ===
在有些情况下,推荐使用isset来判断一个变量是否为NULL。
但是从语义上来说,一个变量”是否已显示初始化“和”是否为NULL“是不同的概念,在某些场景下使用isset是不合适的,比如检查一个函数的返回值是否为NULL。
此时可以使用”==”和”===“来判断它们是否为NULL。
对于”==”和”===“,它们直接的区别还是很大。对于”==”,它认同空字符串,0,false都为NULL。而对于”===”,只有一个变量真的为NULL,它才代表NULL。
另外”===”相对于”isset”来说,性能基本接近,甚至要好点。
因此综上述,判断一个变量是否为NULL最好的办法就是直接使用”===”,这样就不用在is_null,isset之间犹豫。其实上述的结论也同理于False的判断。
附录:
测试代码:
$data = 0;
$data1 = '0';
$data2 = array();
$data3 = null;
$data4 = false;
$data5 = "";
结果:
if (!变量)全部为true
if (isset(变量))全部为true
if (empty(变量))全部为true
if (is_null(变量)) 只有null为true 其他为为false
if (变量==null) 只有'0'为false,其他为true
if (变量===null) 只有null为true,其他false
7、sm尺寸下占1/6,xs尺寸下占全部如何實現?
col-sm-2
col-sm-2
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Email</label> <div class="col-sm-10">
<input type="email" class="form-control" id="inputEmail3" placeholder="Email">
</div>
</div>
8、实现任何看到的样式?
css 查看
因为都是html,css,所以完全可以查看然后copy样式实现相同的效果,非常简单方便
9、聚合查找,查找学校拥有的的班级数?
group
$school_class=db('school_class')->field('sc_s_id,count(sc_s_id)')->group('sc_s_id')->select();
dump($school_class);die;
结果:
array(3) {
[0] => array(2) {
["sc_s_id"] => int(8)
["count(sc_s_id)"] => int(4)
}
[1] => array(2) {
["sc_s_id"] => int(9)
["count(sc_s_id)"] => int(4)
}
[2] => array(2) {
["sc_s_id"] => int(11)
["count(sc_s_id)"] => int(5)
}
}
10、input:file显示样式优化的原理?
重叠 透明度 size 定位
显示出来的是button,button和input重叠了,点到button点到了input
input的透明度是0,input的size是50rem,而且是绝对定位

<div class="fry_file">
<button type="button" class="btn btn-danger btn-sm">
<i class="fa fa-upload"></i> Select images to upload</button>
<input class="fry_file_input" id="doc-form-file" type="file" accept="image/*" name="ep_picture[]" multiple="">
</div>
<div id="file-list"></div>
<!--上傳顯示圖片的js-->
<script>
$(function() {
$('#doc-form-file').on('change', function() {
var fileNames = '';
$.each(this.files, function() {
fileNames += '<span class="badge">' + this.name + '</span> ';
});
$('#file-list').html(fileNames);
});
});
</script>
<!--END 上傳顯示圖片的js-->
/*===================== input_file顯示樣式 =====================*/
.fry_file{
position: relative;overflow: hidden;margin-bottom: 1.5rem;
}
.fry_file .fry_file_input{
position: absolute;left:;top:;z-index:;width: 100%;opacity:;cursor: pointer;font-size: 50rem;
}
二、内容在总结中
m_Orchestrate learning system---三十一、模板和需求的关系的更多相关文章
- m_Orchestrate learning system---十三、thinkphp的验证器支持多语言么
m_Orchestrate learning system---十三.thinkphp的验证器支持多语言么 一.总结 一句话总结:支持,不仅验证器支持,其它的插件应该都支持 不仅thinkphp支持多 ...
- m_Orchestrate learning system---二十一、怎样写算法比较轻松
m_Orchestrate learning system---二十一.怎样写算法比较轻松 一.总结 一句话总结:(1.写出算法步骤,这样非常有利于理清思路,这样就非常简单了 2.把问题分细,小问题用 ...
- m_Orchestrate learning system---mo系统权限思考
m_Orchestrate learning system---mo系统权限思考 一.总结 一句话总结:注意不同身份访问同一客户端时候的权限,比如面板显示,比如功能按钮 权限 面板 功能 1.小组之间 ...
- m_Orchestrate learning system---三十、项目中的dist文件一般是做什么的
m_Orchestrate learning system---三十.项目中的dist文件一般是做什么的 一.总结 一句话总结: Bootstrap switch:dist 目录是放最终的js和css ...
- m_Orchestrate learning system---二十九、什么情况下用数据库做配置字段,什么情况下用配置文件做配置
m_Orchestrate learning system---二十九.什么情况下用数据库做配置字段,什么情况下用配置文件做配置 一.总结 一句话总结: 配置文件 开发人员 重置 数据库 非开发人员 ...
- m_Orchestrate learning system---十一、thinkphp查看临时文件的好处是什么
m_Orchestrate learning system---十一.thinkphp查看临时文件的好处是什么 一.总结 一句话总结:可以知道thinkphp的标签被smarty引擎翻译而来的php代 ...
- Machine Learning - 第6周(Advice for Applying Machine Learning、Machine Learning System Design)
In Week 6, you will be learning about systematically improving your learning algorithm. The videos f ...
- JAVA之旅(三十一)——JAVA的图形化界面,GUI布局,Frame,GUI事件监听机制,Action事件,鼠标事件
JAVA之旅(三十一)--JAVA的图形化界面,GUI布局,Frame,GUI事件监听机制,Action事件,鼠标事件 有段时间没有更新JAVA了,我们今天来说一下JAVA中的图形化界面,也就是GUI ...
- Java进阶(三十一) Web服务调用
Java进阶(三十一) Web服务调用 前言 有朋友问了一个问题:如何调用已知的音乐服务接口,服务文档如下: https://www.evernote.com/shard/s744/sh/c37cd5 ...
随机推荐
- ajax response 系统错误时responseText出现一堆代码
在后期维护webform的一个项目时遇到个比较大的坑,前台ajax请求,失败时弹出后台自定义的错误信息responsetext.结果在本地运行时能正常弹出“验证码错误”,而发布到服务器上respons ...
- POST—GET—两种提交方式的区别
主要区别: 安全性 长度限制 数据结构. 总结起来: get方式:以URL字串本身传递数据参数,在服务器端可以从UERY_STRING'这个变量中直接读取,效率较高,但缺乏安全性,也无法来 ...
- mongodb部署
windows版本 http://dl.mongodb.org/dl/win32/x86_64 安装教程 https://docs.mongodb.org/manual/tutorial/instal ...
- POJ 1836
刚开始二分写错了 wa了很久 这个二分 的好好想想 #include <iostream> #include<cstdio> #include<string.h> ...
- DIV内容垂直居中
css垂直居中属性设置vertical-align: middle对div不起作用,例如: <!DOCTYPE html> <html lang="zh-CN"& ...
- linux常用命令:whereis 命令
whereis命令只能用于程序名的搜索,而且只搜索二进制文件(参数-b).man说明文件(参数-m)和源代码文件(参数-s).如果省略参数,则返回所有信息. 和find相比,whereis查找的速度非 ...
- ping和telnet的区别
内容主要转自: http://jingyan.baidu.com/article/8065f87fc3b31123312498e5.html http://zhidao.baidu.com/link? ...
- MyEclipse2014+JDK1.7+Tomcat8.0+Maven3.2 开发环境搭建
1.JDK的安装 首先下载JDK,这个从sun公司官网可以下载,根据自己的系统选择64位还是32位,安装过程就是next一路到底.安装完成之后当然要配置环境变量了. ————————————————— ...
- 修改Nginx配置文件来隐藏index.php
找到你要修改的域名对应nginx配置文件(vhost下),添加如下代码 location / { if (!-e $request_filename) { rewrite ^(.*)$ /index. ...
- python no module named 'win32api'
在cmd下执行 pip install pypiwin32api 即可