<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>硬汉工作室 - 前端知识</title>
    <link>https://www.nciaer.com/forum-38-1.html</link>
    <description>Latest 20 threads of 前端知识</description>
    <copyright>Copyright(C) 硬汉工作室</copyright>
    <generator>Discuz! Board by Comsenz Inc.</generator>
    <lastBuildDate>Tue, 12 May 2026 11:29:46 +0000</lastBuildDate>
    <ttl>60</ttl>
    <image>
      <url>https://www.nciaer.com/static/image/common/logo_88_31.gif</url>
      <title>硬汉工作室</title>
      <link>https://www.nciaer.com/</link>
    </image>
    <item>
      <title>jquery里ajax用法</title>
      <link>https://www.nciaer.com/thread-2345-1-1.html</link>
      <description><![CDATA[还是那句话，不想每次都百度了，记录下。]]></description>
      <category>前端知识</category>
      <author>nciaer</author>
      <pubDate>Fri, 22 Nov 2024 07:11:07 +0000</pubDate>
    </item>
    <item>
      <title>水平垂直居中页面的div代码</title>
      <link>https://www.nciaer.com/thread-2344-1-1.html</link>
      <description><![CDATA[每次都需要百度，干脆自己记录下来吧，具体原理我也不懂，不过算是比较简单的方法。
定义一个.win的div即可]]></description>
      <category>前端知识</category>
      <author>nciaer</author>
      <pubDate>Wed, 20 Nov 2024 09:49:48 +0000</pubDate>
    </item>
    <item>
      <title>javascript里的Math对象</title>
      <link>https://www.nciaer.com/thread-2341-1-1.html</link>
      <description><![CDATA[Math无需实例化，都是类似静态的方法。

Math.PI; // 返回圆周率3.141592653589793
Math.abs(-10); // 返回参数的绝对值

Math.ceil(4.1); // 向上取整，返回5

Math.floor(4.8); // 向下取整，返回4

Math.round(4.5); // 四舍五入，返回5

Math.random(); // 返回0-1 ...]]></description>
      <category>前端知识</category>
      <author>nciaer</author>
      <pubDate>Tue, 27 Aug 2024 05:55:05 +0000</pubDate>
    </item>
    <item>
      <title>javascript里的Date对象</title>
      <link>https://www.nciaer.com/thread-2340-1-1.html</link>
      <description><![CDATA[1. 创建Date对象：
var myDate = new Date(); // 创建当前日期时间的对象
var myDate = new Date(毫秒时间戳); // 创建指定日期时间的对象
var myDate = new Date(\'2024-08-27 09:01:23\') // 创建指定日期的对象
var myDate = new Date(2024, 8, 27, 9, 1, 23, 100); // ...]]></description>
      <category>前端知识</category>
      <author>nciaer</author>
      <pubDate>Tue, 27 Aug 2024 01:15:09 +0000</pubDate>
    </item>
    <item>
      <title>html5里的Notification通知</title>
      <link>https://www.nciaer.com/thread-2338-1-1.html</link>
      <description><![CDATA[Notification可以实现在系统桌面上弹窗，前提当然是浏览器不能关，写Notification代码的页面也不能关，下面介绍一些简单用法。

首先判断浏览器是否支持这个功能：if(window.Notification) {// code}。
其次这个权限需要用户主动确认允许才行，通过Notification.request ...]]></description>
      <category>前端知识</category>
      <author>nciaer</author>
      <pubDate>Fri, 02 Aug 2024 08:30:48 +0000</pubDate>
    </item>
    <item>
      <title>javascript对象学习</title>
      <link>https://www.nciaer.com/thread-2335-1-1.html</link>
      <description><![CDATA[1. 创建一个对象：
let obj = {}; // 创建了一个空的对象
let people = {name: \'nciaer\', age: 35}; // 创建了有name和age属性的对象，注意属性可以加引号，也可以不加，通常不需要加，但是如果属性有特殊符号，比如name-1，那就必须要加引号。json格式跟js对象差不多， ...]]></description>
      <category>前端知识</category>
      <author>nciaer</author>
      <pubDate>Fri, 12 Jul 2024 05:47:40 +0000</pubDate>
    </item>
    <item>
      <title>利用cropper.js实现选择图片裁剪上传</title>
      <link>https://www.nciaer.com/thread-2328-1-1.html</link>
      <description><![CDATA[公司还是用的phpcms系统，头像上传还是用的flash，导致大部分浏览器都无法用了，只能升级了。

用的cropper.js

核心代码如下：


几点注意下：
formData对象可以直接添加文件数据，并且不需要设置contentType类型；

重新选择图片，必须用cropper.replace方法设置新图 ...]]></description>
      <category>前端知识</category>
      <author>nciaer</author>
      <pubDate>Tue, 20 Feb 2024 07:46:38 +0000</pubDate>
    </item>
    <item>
      <title>异步加载的js代码，第二次不执行是咋回事？</title>
      <link>https://www.nciaer.com/thread-1869-1-1.html</link>
      <description><![CDATA[今天改dz的一个小功能，点击某个按钮异步加载一段js执行，但是奇怪的是，点击第一次js正常执行，第二次不行，数据成功请求回来了，但是js没有反应。后来经过测试发现，返回的js内容一摸一样的情况下，第二次是不会执行的，这就好办了，在js里随便动态生成点内容，让每次 ...]]></description>
      <category>前端知识</category>
      <author>nciaer</author>
      <pubDate>Wed, 14 Jun 2023 01:39:08 +0000</pubDate>
    </item>
    <item>
      <title>html里的select组件知识记录</title>
      <link>https://www.nciaer.com/thread-1797-1-1.html</link>
      <description><![CDATA[每次想要用到都得百度，干脆自己记录下吧。

主要也就是用select的下拉选择事件，用户选择其中一项后，触发事件，直接上代码：

    请选择板块
    板块1
    板块2
    板块3



    $(\'#fid\').change(function() {
        var txt = $(\&quot;#fid option:selected\&quot;).text ...]]></description>
      <category>前端知识</category>
      <author>nciaer</author>
      <pubDate>Tue, 06 Dec 2022 09:22:02 +0000</pubDate>
    </item>
    <item>
      <title>关于js的on和click方法</title>
      <link>https://www.nciaer.com/thread-1795-1-1.html</link>
      <description><![CDATA[多年没研究jq了。最近在接一个小单子用到click事件，用之前的(\'.dialog\').click(function() {})明显不好使，没反应。百度后发现动态生成的dom无法使用click直接绑定，需要用on方法。直接上个例子：
$(\'body\').on(\'click\', \'.dialog\', function() {});
其中on前面的元素 ...]]></description>
      <category>前端知识</category>
      <author>nciaer</author>
      <pubDate>Fri, 09 Sep 2022 08:36:19 +0000</pubDate>
    </item>
    <item>
      <title>js上传文件</title>
      <link>https://www.nciaer.com/thread-1788-1-1.html</link>
      <description><![CDATA[之前用的也就是form表单上传，还从来没有用过用js上传，form表单只能同步上传，js上传就可以异步上传了。

下面是html部分：

]]></description>
      <category>前端知识</category>
      <author>nciaer</author>
      <pubDate>Tue, 08 Mar 2022 09:09:06 +0000</pubDate>
    </item>
    <item>
      <title>layer里获取content内容里表单的值</title>
      <link>https://www.nciaer.com/thread-1787-1-1.html</link>
      <description><![CDATA[我做的一个弹窗小插件，用的layer库，主要代码如下：layer.ready(function() {
        layer.open({
                type: 0,
                title: \'标题\',
                content: $(\'#popup_content\').html(),
                skin: \'\',
                area ...]]></description>
      <category>前端知识</category>
      <author>nciaer</author>
      <pubDate>Fri, 04 Mar 2022 02:40:31 +0000</pubDate>
    </item>
    <item>
      <title>jquery的serialize方法的坑</title>
      <link>https://www.nciaer.com/thread-1784-1-1.html</link>
      <description><![CDATA[之前其实没用过这个serialize方法的，今天百度了下：serialize() 方法通过序列化表单值，并且可以直接用在ajax里的data属性。创建 URL 编码文本字符串。我自己写了个例子，比如如下表单：

    
    
    
    



    function chk(o) {
        alert($(o).serialize( ...]]></description>
      <category>前端知识</category>
      <author>nciaer</author>
      <pubDate>Thu, 17 Feb 2022 07:44:33 +0000</pubDate>
    </item>
    <item>
      <title>html中input和select宽度不一致问题</title>
      <link>https://www.nciaer.com/thread-1783-1-1.html</link>
      <description><![CDATA[其实一直遇到这个问题，每次都是调试，让它保持宽度一致，一直也不明白为什么，今天百度了下，终于明白了，记录下来。
先说说box-sizing属性，它有两个值：
border-box，这个值表示元素的宽度是内容的宽度width+padding+border的宽度的和
content-box，这个值表示元素的 ...]]></description>
      <category>前端知识</category>
      <author>nciaer</author>
      <pubDate>Thu, 17 Feb 2022 03:50:11 +0000</pubDate>
    </item>
    <item>
      <title>html里点击button为什么会提交表单？</title>
      <link>https://www.nciaer.com/thread-1778-1-1.html</link>
      <description><![CDATA[页面里经常需要用到按钮，用的时候发现，点击它会自动提交表单，不知道为啥，因为我提交表单一般都是用的，百度了下，原来button的type属性默认是submit，也就是提交功能，如果想用它当作普通按钮，需要指定type=\&quot;button\&quot;，也就是：clickme

刚才用js测试了下，发现butt ...]]></description>
      <category>前端知识</category>
      <author>nciaer</author>
      <pubDate>Fri, 07 Jan 2022 03:43:11 +0000</pubDate>
    </item>
    <item>
      <title>关于一次微信分享错误的记录</title>
      <link>https://www.nciaer.com/thread-1691-1-1.html</link>
      <description><![CDATA[客户的一个网站，微信分享提示：invalid signature，老生常谈的错误，要么是没有加入js安全域名，要么就是没有加入IP白名单，但是这两个都不是，奇怪的很。

最后测试发现是客户前台是通过https访问的，但是jssdk里生成的链接却是http开头的，就这个问题。
 ...]]></description>
      <category>前端知识</category>
      <author>nciaer</author>
      <pubDate>Thu, 02 Sep 2021 07:56:37 +0000</pubDate>
    </item>
    <item>
      <title>关于layer.js弹窗按钮错位的解决办法</title>
      <link>https://www.nciaer.com/thread-1673-1-1.html</link>
      <description><![CDATA[用layer.js做弹窗很不错，但是有个问题就是第一次加载可能会造成按钮错位，仅限于pc端，也不知道为啥。百度了一堆也没找到解决办法。后来又看了看API文档，原来让layer的代码在layer.ready(function() {});里执行就ok了。 ...]]></description>
      <category>前端知识</category>
      <author>nciaer</author>
      <pubDate>Wed, 14 Apr 2021 06:08:48 +0000</pubDate>
    </item>
    <item>
      <title>H5页面和小程序封装的H5来回跳转代码</title>
      <link>https://www.nciaer.com/thread-1670-1-1.html</link>
      <description><![CDATA[点我
]]></description>
      <category>前端知识</category>
      <author>nciaer</author>
      <pubDate>Mon, 22 Feb 2021 08:45:57 +0000</pubDate>
    </item>
    <item>
      <title>addEventListener与attachEvent与on事件</title>
      <link>https://www.nciaer.com/thread-1653-1-1.html</link>
      <description><![CDATA[addEventlistener是W3C标准的绑定事件监听函数的方法，IE9+及其它浏览器都支持，而attachEvent是IE8-绑定事件函数的方法。

addEventListener的标准用法如下：
domObj.addEventLisetener(\'click\', function() {
    alert(\'hello\');
})

一共2个参数，第一个参数是绑定 ...]]></description>
      <category>前端知识</category>
      <author>nciaer</author>
      <pubDate>Tue, 29 Sep 2020 06:25:11 +0000</pubDate>
    </item>
    <item>
      <title>js上传图片预览图</title>
      <link>https://www.nciaer.com/thread-1625-1-1.html</link>
      <description><![CDATA[百度得到得方法，记录下来。

这个这是选择图片后增加预览而已。

先上效果图：



先说说上传按钮优化的原理，点击上传签购单是一个图片，作为图片预览区域，那个上传控件以绝对定位的形式覆盖在了这个图片上面，然后设置opacity=0，使上传控件不可见，这样点击图片就 ...]]></description>
      <category>前端知识</category>
      <author>nciaer</author>
      <pubDate>Wed, 29 Apr 2020 07:40:48 +0000</pubDate>
    </item>
  </channel>
</rss>