xt-laravel-admin/public/static/admin/js/module/tool.js
2018-12-16 11:38:44 +08:00

34 lines
896 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

layui.define(['jquery'], function (exports) {
var $ = layui.jquery;
var tool = {
/**
* 移除数组的值
* @param arr 数组
* @param val 删除的值
*/
removeByValue: function (arr, val) {
for (var i = 0; i < arr.length; i++) {
if (arr[i] == val) {
arr.splice(i, 1);
break;
}
}
},
/**
* 转义字符防止xxs
* @param str
* @returns {string}
*/
stringEncode:function (str){
var div=document.createElement('div');
if(div.innerText){
div.innerText=str;
}else{
div.textContent=str;//Support firefox
}
return div.innerHTML;
}
};
exports('tool', tool);
});