<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>VickyWu</title>
    <description>与你一起发现更大的世界。</description>
    <link>https://wuhongshan.github.io//</link>
    <atom:link href="https://wuhongshan.github.io//feed.xml" rel="self" type="application/rss+xml" />
    <pubDate>Tue, 21 Nov 2017 05:36:23 +0000</pubDate>
    <lastBuildDate>Tue, 21 Nov 2017 05:36:23 +0000</lastBuildDate>
    <generator>Jekyll v3.6.2</generator>
    
      <item>
        <title>css揭秘</title>
        <description>&lt;h1 id=&quot;css揭秘&quot;&gt;css揭秘&lt;/h1&gt;

&lt;h3 id=&quot;1css编码技巧&quot;&gt;1、CSS编码技巧&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;尽量减少代码重复
在某些值相互依赖时，应把他们的相互关系用代码表示出来。
如:行高是字号的2倍，&lt;code class=&quot;highlighter-rouge&quot;&gt;font-size:20px&lt;/code&gt;(可使用百分比和em);&lt;code class=&quot;highlighter-rouge&quot;&gt;line-height:2&lt;/code&gt;;&lt;/li&gt;
  &lt;li&gt;代码易维护和代码量少不可兼得
 如:&lt;code class=&quot;highlighter-rouge&quot;&gt;border-width:10px 10px 10px 5px&lt;/code&gt;,(代码量少);
 如:&lt;code class=&quot;highlighter-rouge&quot;&gt;border-width:10px;
border-left-width:5px;&lt;/code&gt;(易维护);&lt;/li&gt;
  &lt;li&gt;响应式网页设计
 实现弹性可伸缩的布局，并在媒体查询的各个断点区间内指定相应尺寸。
如:
    &lt;ul&gt;
      &lt;li&gt;使用百分比取代固定宽度、长度;&lt;/li&gt;
      &lt;li&gt;当图片以行列式布局时，&lt;code class=&quot;highlighter-rouge&quot;&gt;display:inline-block&lt;/code&gt;或&lt;code class=&quot;highlighter-rouge&quot;&gt;display:flex&lt;/code&gt;可以实现;&lt;/li&gt;
      &lt;li&gt;为替换元素(浏览器根据元素的标签和属性决定元素具体显示内容,如img、video)设&lt;code class=&quot;highlighter-rouge&quot;&gt;max-width:100%&lt;/code&gt;;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;2用户体验&quot;&gt;2、用户体验&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;选用合适的鼠标光标
 如:
    &lt;ul&gt;
      &lt;li&gt;表单提交后设置&lt;code class=&quot;highlighter-rouge&quot;&gt;cursor:not-allowed&lt;/code&gt;;&lt;/li&gt;
      &lt;li&gt;视频播放器&lt;code class=&quot;highlighter-rouge&quot;&gt;cursor:none&lt;/code&gt;;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;扩大可点击区域
 &lt;code class=&quot;highlighter-rouge&quot;&gt;border:10px solid transparent;background-clip:padding-box&lt;/code&gt;
若还需设置border时不适用。此时可利用伪类&lt;code class=&quot;highlighter-rouge&quot;&gt;position:absolute&lt;/code&gt;覆盖。&lt;/li&gt;
  &lt;li&gt;自定义复选框
    &lt;ul&gt;
      &lt;li&gt;1.隐藏原样式&lt;code class=&quot;highlighter-rouge&quot;&gt;position:absolute;clip:rect(0 0 0 0);&lt;/code&gt;&lt;a href=&quot;http://www.zhangxinxu.com/study/201103/css-rect-demo.html&quot;&gt;rect demo&lt;/a&gt;
 2.相邻label伪类覆盖原位置
ps : left &amp;gt;= right或者bottom &amp;lt;= top，则元素会被完全裁掉而不可见，即“隐藏”。通过这种方式隐藏的元素是可以被屏幕阅读器等辅助设备识别的.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;3结构与布局&quot;&gt;3、结构与布局&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;自适应内部元素
 &lt;code class=&quot;highlighter-rouge&quot;&gt;width: min-content;&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;垂直居中
    &lt;ul&gt;
      &lt;li&gt;1.父元素：&lt;code class=&quot;highlighter-rouge&quot;&gt;display:flex;align-items:center;justify-content:center&lt;/code&gt;;&lt;/li&gt;
      &lt;li&gt;2.父元素：&lt;code class=&quot;highlighter-rouge&quot;&gt;display:flex;&lt;/code&gt;子元素：&lt;code class=&quot;highlighter-rouge&quot;&gt;margin:auto&lt;/code&gt;;&lt;/li&gt;
      &lt;li&gt;3.&lt;code class=&quot;highlighter-rouge&quot;&gt;padding: 100px calc(50% - 50px)&lt;/code&gt;;&lt;/li&gt;
      &lt;li&gt;4.视口居中
 子元素&lt;code class=&quot;highlighter-rouge&quot;&gt;margin: 50vh auto 0;transform: translateY(-50%);&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;根据数量设置样式
    &lt;ul&gt;
      &lt;li&gt;1.一个&lt;code class=&quot;highlighter-rouge&quot;&gt;li:only-child&lt;/code&gt;;&lt;/li&gt;
      &lt;li&gt;2.n个
```css
li:first-child:nth-last-child(n),
li:first-child:nth-last-child(n)~li{&lt;/li&gt;
    &lt;/ul&gt;

    &lt;p&gt;}&lt;/p&gt;
    &lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;- 3.小于n个
```css
li:first-child:nth-last-child(-a+n),
li:first-child:nth-last-child(-a+n)~li{
    
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
    &lt;ul&gt;
      &lt;li&gt;4.大于n个
```css
li:first-child:nth-last-child(a+n),
li:first-child:nth-last-child(a+n)~li{&lt;/li&gt;
    &lt;/ul&gt;

    &lt;p&gt;}
```&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

</description>
        <pubDate>Tue, 21 Nov 2017 00:00:00 +0000</pubDate>
        <link>https://wuhongshan.github.io//css/2017/11/21/css%E6%8F%AD%E7%A7%98/</link>
        <guid isPermaLink="true">https://wuhongshan.github.io//css/2017/11/21/css%E6%8F%AD%E7%A7%98/</guid>
        
        <category>css</category>
        
        
        <category>css</category>
        
      </item>
    
      <item>
        <title>iphoneX适配</title>
        <description>&lt;h1 id=&quot;iphonex适配&quot;&gt;iphoneX适配&lt;/h1&gt;

&lt;h4 id=&quot;使用安全区域&quot;&gt;使用安全区域&lt;/h4&gt;
&lt;p&gt;iPhone X的Safari浏览器中页面显示都具有边缘。内容自动设置在显示的安全区域内，不会被圆角或设备的传感器外壳遮挡住（俗称iPhone X的刘海）。
如图：&lt;img src=&quot;http://od6qpmkyu.bkt.clouddn.com/wuhongshan/md/iphoneX%E9%80%82%E9%85%8D-1.png&quot; alt=&quot;此处输入图片的描述&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;使用整个屏幕&quot;&gt;使用整个屏幕&lt;/h4&gt;
&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'viewport'&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;viewport-fit=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'cover'&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;viewport-fit&lt;/code&gt; 默认为auto，效果为上图。&lt;/p&gt;

&lt;h4 id=&quot;使用整个屏幕的同时需要应用内距&quot;&gt;使用整个屏幕的同时，需要应用内距&lt;/h4&gt;

&lt;p&gt;iOS 11中的WebKit包含了一个新的CSS函数&lt;code class=&quot;highlighter-rouge&quot;&gt;constant()&lt;/code&gt;，以及一组四个预定义的常量：&lt;code class=&quot;highlighter-rouge&quot;&gt;safe-area-inset-left&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;safe-area-inset-right&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;safe-area-inset-top&lt;/code&gt;和 &lt;code class=&quot;highlighter-rouge&quot;&gt;safe-area-inset-bottom&lt;/code&gt;。当合并一起使用时，允许样式引用每个方面的安全区域的大小。不支持&lt;code class=&quot;highlighter-rouge&quot;&gt;constant()&lt;/code&gt;的浏览器，会自动忽略。&lt;/p&gt;
&lt;div class=&quot;language-css highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nc&quot;&gt;.post&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; 
    &lt;span class=&quot;nl&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;12px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; 
    &lt;span class=&quot;nl&quot;&gt;padding-left&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;constant&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;safe-area-inset-left&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; 
    &lt;span class=&quot;nl&quot;&gt;padding-right&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;constant&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;safe-area-inset-right&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; 
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;但在竖屏时，左右的安全区域变成了0px。
&lt;img src=&quot;http://od6qpmkyu.bkt.clouddn.com/wuhongshan/md/iphoneX%E9%80%82%E9%85%8D-4.png&quot; alt=&quot;此处输入图片的描述&quot; /&gt;
因此需要min()或max().两个函数都采用任意数量的参数，并返回最小值或最大值。它们可以在calc()中使用，或者嵌套在一起，这两个函数都允许像calc()一样的数学计算&lt;/p&gt;

&lt;p&gt;终极版css&lt;/p&gt;
&lt;div class=&quot;language-css highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;@supports&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;0px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; 
    &lt;span class=&quot;nc&quot;&gt;.post&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; 
        &lt;span class=&quot;nl&quot;&gt;padding-left&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;12px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;constant&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;safe-area-inset-left&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;          
        &lt;span class=&quot;nl&quot;&gt;padding-right&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;12px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;constant&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;safe-area-inset-right&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</description>
        <pubDate>Fri, 10 Nov 2017 00:00:00 +0000</pubDate>
        <link>https://wuhongshan.github.io//iphonex%E9%80%82%E9%85%8D/2017/11/10/iphoneX%E9%80%82%E9%85%8D/</link>
        <guid isPermaLink="true">https://wuhongshan.github.io//iphonex%E9%80%82%E9%85%8D/2017/11/10/iphoneX%E9%80%82%E9%85%8D/</guid>
        
        <category>css</category>
        
        
        <category>iphoneX适配</category>
        
      </item>
    
      <item>
        <title>vue钩子函数</title>
        <description>&lt;h1 id=&quot;vue钩子函数&quot;&gt;vue钩子函数&lt;/h1&gt;

&lt;h3 id=&quot;vue生命周期简介&quot;&gt;vue生命周期简介&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;http://od6qpmkyu.bkt.clouddn.com/wuhongshan/md/vue%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F.png&quot; alt=&quot;vue生命周期&quot; /&gt;
vue1.x与2.x生命周期对比
&lt;img src=&quot;http://od6qpmkyu.bkt.clouddn.com/wuhongshan/md/vue%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E5%AF%B9%E6%AF%94.png&quot; alt=&quot;vue1.x与2.x生命周期对比&quot; /&gt;&lt;/p&gt;
&lt;h4 id=&quot;ps&quot;&gt;ps:&lt;/h4&gt;
&lt;p&gt;1.&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;keep-alive&amp;gt;&lt;/code&gt;包裹动态组件时，会缓存不活动的组件实例，而不是销毁它们，因此当组件在 &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;keep-alive&amp;gt;&lt;/code&gt; 内被切换，它的 &lt;code class=&quot;highlighter-rouge&quot;&gt;activated&lt;/code&gt; 和 &lt;code class=&quot;highlighter-rouge&quot;&gt;deactivated&lt;/code&gt; 这两个生命周期钩子函数将会被对应执行，而没有   &lt;code class=&quot;highlighter-rouge&quot;&gt;beforeDestroy&lt;/code&gt;和&lt;code class=&quot;highlighter-rouge&quot;&gt;destroyed&lt;/code&gt;这两个生命周期钩子函数。
2、&lt;code class=&quot;highlighter-rouge&quot;&gt;beforeCreate&lt;/code&gt;：el和data还没有初始化，可用于loading。
3、&lt;code class=&quot;highlighter-rouge&quot;&gt;created&lt;/code&gt;：完成了data初始化，el还没有，请求接口数据。
4、&lt;code class=&quot;highlighter-rouge&quot;&gt;beforeMount&lt;/code&gt;：完成了el、data初始化。
5、&lt;code class=&quot;highlighter-rouge&quot;&gt;mounted&lt;/code&gt;挂载完成，可通过$refs获取dom，data值渲染到了对应的dom位置。&lt;code class=&quot;highlighter-rouge&quot;&gt;mounted&lt;/code&gt;前先以的形式占住dom，在&lt;code class=&quot;highlighter-rouge&quot;&gt;mounted&lt;/code&gt;时进行数据渲染。
6、data、store里的值发生改变，都会触发&lt;code class=&quot;highlighter-rouge&quot;&gt;beforeUpdate&lt;/code&gt;、&lt;code class=&quot;highlighter-rouge&quot;&gt;updated&lt;/code&gt;。&lt;/p&gt;

&lt;p&gt;详见
&lt;img src=&quot;http://od6qpmkyu.bkt.clouddn.com/vue%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E6%BC%94%E7%A4%BA-3.png&quot; alt=&quot;打印&quot; /&gt;&lt;img src=&quot;http://od6qpmkyu.bkt.clouddn.com/vue%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E6%BC%94%E7%A4%BA-1.png&quot; alt=&quot;打印结果1&quot; /&gt;&lt;img src=&quot;http://od6qpmkyu.bkt.clouddn.com/vue%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E6%BC%94%E7%A4%BA-2.png&quot; alt=&quot;打印结果2&quot; /&gt;&lt;/p&gt;

</description>
        <pubDate>Wed, 01 Nov 2017 00:00:00 +0000</pubDate>
        <link>https://wuhongshan.github.io//vue/2017/11/01/vue%E9%92%A9%E5%AD%90%E5%87%BD%E6%95%B0/</link>
        <guid isPermaLink="true">https://wuhongshan.github.io//vue/2017/11/01/vue%E9%92%A9%E5%AD%90%E5%87%BD%E6%95%B0/</guid>
        
        <category>框架</category>
        
        
        <category>vue</category>
        
      </item>
    
      <item>
        <title>关于redux</title>
        <description>&lt;h1 id=&quot;关于redux&quot;&gt;关于redux&lt;/h1&gt;

&lt;h3 id=&quot;设计原则&quot;&gt;设计原则&lt;/h3&gt;

&lt;p&gt;1.唯一数据源
2.状态只读
3.数据改变只能通过纯函数完成（即reducer为纯函数）&lt;/p&gt;

&lt;h3 id=&quot;基本概念&quot;&gt;基本概念&lt;/h3&gt;

&lt;p&gt;1.store
Store 就是保存数据的地方，你可以把它看成一个容器。整个应用只能有一个 Store。
Redux 提供createStore这个函数，用来生成 Store。&lt;/p&gt;
&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;createStore&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'redux'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;store&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;createStore&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;2.state
Store对象包含所有数据。如果想得到某个时点的数据，就要对 Store 生成快照。这种时点的数据集合，就叫做 State。
当前时刻的 State，可以通过store.getState()拿到。&lt;/p&gt;
&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;createStore&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'redux'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;store&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;createStore&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;state&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;getState&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Redux 规定， 一个 State 对应一个 View。只要 State 相同，View 就相同。
3.action
Action 是一个对象。用于view发出通知，表示state要发生变化。其中的type属性是必须的，表示 Action 的名称。其他属性可以自由设置。&lt;/p&gt;
&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;action&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'ADD_TODO'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;payload&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'Learn Redux'&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;基本操作&quot;&gt;基本操作&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;http://od6qpmkyu.bkt.clouddn.com/wuhongshan/md/react.png&quot; alt=&quot;此处输入图片的描述&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;注意&quot;&gt;注意&lt;/h3&gt;
&lt;p&gt;1.按照功能组织代码
&lt;img src=&quot;http://od6qpmkyu.bkt.clouddn.com/wuhongshan/md/%E6%8C%89%E5%8A%9F%E8%83%BD%E5%88%92%E5%88%86%E4%BB%A3%E7%A0%81.png&quot; alt=&quot;此处输入图片的描述&quot; /&gt;
2.保持state范式化
&lt;img src=&quot;http://od6qpmkyu.bkt.clouddn.com/wuhongshan/md/%E8%8C%83%E5%BC%8F%E5%8C%96.png&quot; alt=&quot;此处输入图片的描述&quot; /&gt;
3.保持state扁平化
&lt;img src=&quot;http://od6qpmkyu.bkt.clouddn.com/wuhongshan/md/%E6%89%81%E5%B9%B3%E5%8C%96.png&quot; alt=&quot;此处输入图片的描述&quot; /&gt;
4.用selector读state
&lt;img src=&quot;http://od6qpmkyu.bkt.clouddn.com/reselect.png&quot; alt=&quot;此处输入图片的描述&quot; /&gt;
&lt;img src=&quot;http://od6qpmkyu.bkt.clouddn.com/relector%E5%AE%9E%E4%BE%8B.png&quot; alt=&quot;此处输入图片的描述&quot; /&gt;
5.分离容器组件和傻瓜组件
&lt;img src=&quot;http://od6qpmkyu.bkt.clouddn.com/wuhongshan/md/%E5%88%86%E7%A6%BB%E5%AE%B9%E5%99%A8%E7%BB%84%E4%BB%B6%E5%92%8C%E5%82%BB%E7%93%9C%E7%BB%84%E4%BB%B6.png&quot; alt=&quot;此处输入图片的描述&quot; /&gt;
6.使用react-redux&lt;/p&gt;

&lt;p&gt;7.标准化action
&lt;img src=&quot;http://od6qpmkyu.bkt.clouddn.com/wuhongshan/md/action.png&quot; alt=&quot;此处输入图片的描述&quot; /&gt;
8.使用creator创建action creator&lt;/p&gt;
&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;createActionCreator&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;payload&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(...&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;payload&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;typeof&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;payload&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'function'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;payload&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(...&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;payload&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;9.使用函数创造reducer
&lt;img src=&quot;http://od6qpmkyu.bkt.clouddn.com/wuhongshan/md/reducer.png&quot; alt=&quot;此处输入图片的描述&quot; /&gt;
&lt;img src=&quot;http://od6qpmkyu.bkt.clouddn.com/wuhongshan/md/createReducer.png&quot; alt=&quot;此处输入图片的描述&quot; /&gt;
10.使用redux-immutable-addons
11.使用合适的异步处理方式&lt;/p&gt;

</description>
        <pubDate>Thu, 10 Aug 2017 00:00:00 +0000</pubDate>
        <link>https://wuhongshan.github.io//react/2017/08/10/redux/</link>
        <guid isPermaLink="true">https://wuhongshan.github.io//react/2017/08/10/redux/</guid>
        
        <category>框架</category>
        
        
        <category>react</category>
        
      </item>
    
      <item>
        <title>关于富文本编辑器</title>
        <description>&lt;h2 id=&quot;原理&quot;&gt;原理：&lt;/h2&gt;

&lt;p&gt;1.嵌入一个iframe
2.对iframe中的body设置designMode=’on’或contentEditable=’on’
3.对操作的click事件设置document.execCommand(命令名[,交互方式,动态参数])方法&lt;/p&gt;

&lt;h2 id=&quot;可视化编辑&quot;&gt;可视化编辑&lt;/h2&gt;

&lt;p&gt;可以使用contentEditable或designMode
###designMode
只能将document整体设为编辑模式
###contentEditable
可讲任何HTML元素转为可编辑状态&lt;/p&gt;

&lt;h2 id=&quot;ie兼容问题&quot;&gt;IE兼容问题&lt;/h2&gt;

&lt;p&gt;1.在IE使用designMode，调用document.domain时报错（没有权限）
解决（使用contentEditable）
2.在IE使用designMode，右键菜单没有粘贴复制功能
解决（使用contentEditable）
3.IE6/IE7使用contentEditable，编辑区会自动获取焦点&lt;/p&gt;

&lt;h2 id=&quot;execcommand&quot;&gt;execCommand&lt;/h2&gt;

&lt;p&gt;execCommand()是执行一个对当前文档，当前选择或者给出范围的命令。处理Html数据时常用如下格式：&lt;code class=&quot;highlighter-rouge&quot;&gt;document.execCommand(sCommand[,交互方式, 动态参数])&lt;/code&gt;，其中：sCommand为指令参数，交互方式参数如果是true的话将显示对话框，如果为false的话，则不显示对话框（下例中的”false”即表示不显示对话框），动态参数一般为一可用值或属性值&lt;/p&gt;

&lt;h2 id=&quot;好用的富文本编辑器&quot;&gt;好用的富文本编辑器&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;http://kindeditor.net/demo.php&quot;&gt;kindEditor&lt;/a&gt;
&lt;a href=&quot;http://ckeditor.com/&quot;&gt;ckeditor&lt;/a&gt;&lt;/p&gt;

</description>
        <pubDate>Sat, 03 Jun 2017 00:00:00 +0000</pubDate>
        <link>https://wuhongshan.github.io//%E5%AF%8C%E6%96%87%E6%9C%AC%E7%BC%96%E8%BE%91%E5%99%A8/2017/06/03/%E5%85%B3%E4%BA%8E%E5%AF%8C%E6%96%87%E6%9C%AC%E7%BC%96%E8%BE%91%E5%99%A8/</link>
        <guid isPermaLink="true">https://wuhongshan.github.io//%E5%AF%8C%E6%96%87%E6%9C%AC%E7%BC%96%E8%BE%91%E5%99%A8/2017/06/03/%E5%85%B3%E4%BA%8E%E5%AF%8C%E6%96%87%E6%9C%AC%E7%BC%96%E8%BE%91%E5%99%A8/</guid>
        
        <category>功能</category>
        
        
        <category>富文本编辑器</category>
        
      </item>
    
      <item>
        <title>判断变量类型</title>
        <description>&lt;h3 id=&quot;利用typeof&quot;&gt;利用typeof&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;语法&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;类型&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;typeof(‘111’)&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;string&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;typeof(111)&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;number&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;typeof([111])&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;object&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;typeof({1:1})&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;object&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;typeof(function(){})&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;function&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;typeof(/w/)&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;object&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;typeof(null)&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;object&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h3 id=&quot;利用instance-of--和---利用原型链&quot;&gt;利用instance of  和   利用原型链&lt;/h3&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;A&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;instance&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;of&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;B&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;A在B的原型链上&lt;/p&gt;

&lt;p&gt;同利用原型链&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;_instanceof&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;O&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;prototype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;// 取B的显示原型&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;A&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;__proto__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;// 取A的隐式原型&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;//Object.prototype.__proto__ === null&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;A&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;O&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;// 这里重点：当 O 严格等于 A 时，返回 true&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;nx&quot;&gt;A&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;__proto__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;通用方法&quot;&gt;通用方法&lt;/h3&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;isArray&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;prototype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'[object Array]'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;isString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;prototype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'[object String]'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;isNumber&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;prototype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'[object Number]'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;isFunction&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;prototype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'[object Function]'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;isNull&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;prototype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'[object Null]'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;isRegExp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;prototype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'[object RegExp]'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;has&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;          
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;prototype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'[object Array]'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
                &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;prototype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'[object Object]'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</description>
        <pubDate>Thu, 20 Apr 2017 00:00:00 +0000</pubDate>
        <link>https://wuhongshan.github.io//js/2017/04/20/%E5%8F%98%E9%87%8F%E7%B1%BB%E5%9E%8B%E5%88%A4%E6%96%AD/</link>
        <guid isPermaLink="true">https://wuhongshan.github.io//js/2017/04/20/%E5%8F%98%E9%87%8F%E7%B1%BB%E5%9E%8B%E5%88%A4%E6%96%AD/</guid>
        
        <category>js</category>
        
        
        <category>js</category>
        
      </item>
    
      <item>
        <title>字符串编码</title>
        <description>&lt;p&gt;JavaScript中有三个可以对字符串编码的函数，分别是： escape,encodeURI,encodeURIComponent，相应3个解码函数：unescape,decodeURI,decodeURIComponent 。&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;函数名&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;用法&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;参数&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;返回值&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;说明&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;escape(string)&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;编码字符串&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;字符串&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;编码的string副本&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;不会对 ASCII 字母、标点符号（ - _ . ! ~ * ‘ ( ) ）和数字进行编码&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;enCodeURI(URIstring)&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;把字符串作为URI编码&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;含有 URI 或其他要编码的字符串&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;编码的URIstring副本&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;不会对 ASCII 字母、标点符号（ - _ . ! ~ * ‘ ( );/?:@&amp;amp;=+$,# ）和数字进行编码&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;enCodeURIComponent(URIstring)&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;把字符串作为URI编码&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;含有 URI 或其他要编码的字符串&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;编码的URIstring副本&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;不会对 ASCII 字母、标点符号（ - _ . ! ~ * ‘ ( )）和数字进行编码&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;区别：
|函数|区别|
|:—:|:—:|
|escape(string)|除了 ASCII 字母、数字和特定的符号外，对传进来的字符串全部进行转义编码，因此如果想对URL编码，最好不要使用此方法|
|enCodeURI|用于编码整个URI,URI中的合法字符都不会被编码转换|
|enCodeURIComponent|用于编码单个URIComponent（指请求参 数。可以将参数中的中文、特殊字符进行转义，而不会影响整个URL|&lt;/p&gt;

&lt;h4 id=&quot;事例&quot;&gt;事例&lt;/h4&gt;
&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;encodeURI&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'https://item.taobao.com/item.htm?spm=5148.8342959.694504.25.FysMb6&amp;amp;id=12945236853'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;结果：&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;https&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;//item.taobao.com/item.htm?spm=5148.8342959.694504.25.FysMb6&amp;amp;id=12945236853&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;encodeURIComponent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'https://item.taobao.com/item.htm?spm=5148.8342959.694504.25.FysMb6&amp;amp;id=12945236853'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;结果：&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;https&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;F&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Fitem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;taobao&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Fitem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;htm&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Fspm&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;D5148&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;8342959.694504&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;25&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;FysMb6&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;26&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;D12945236853&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;escape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'https://item.taobao.com/item.htm?spm=5148.8342959.694504.25.FysMb6&amp;amp;id=12945236853'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;结果：&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;https&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;//item.taobao.com/item.htm%3Fspm%3D5148.8342959.694504.25.FysMb6%26id%3D12945236853&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
        <pubDate>Sat, 15 Apr 2017 00:00:00 +0000</pubDate>
        <link>https://wuhongshan.github.io//js/2017/04/15/%E5%AD%97%E7%AC%A6%E4%B8%B2%E7%BC%96%E7%A0%81/</link>
        <guid isPermaLink="true">https://wuhongshan.github.io//js/2017/04/15/%E5%AD%97%E7%AC%A6%E4%B8%B2%E7%BC%96%E7%A0%81/</guid>
        
        <category>js</category>
        
        
        <category>js</category>
        
      </item>
    
      <item>
        <title>H5文件操作API</title>
        <description>&lt;h2 id=&quot;关于文件操作的几个重要js对象&quot;&gt;关于文件操作的几个重要JS对象&lt;/h2&gt;

&lt;h3 id=&quot;1blob对象&quot;&gt;1.Blob对象&lt;/h3&gt;

&lt;p&gt;Blob是原始数据对象，提供了slice方法（获取某块数据），size（数据大小）、type（数据MIME类型）属性。&lt;/p&gt;

&lt;h3 id=&quot;2filelist对象&quot;&gt;2.FileList对象&lt;/h3&gt;

&lt;p&gt;File对象的集合。&lt;/p&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;file&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;File&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;#File&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;files&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;变量file即为FileList对象。&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://od6qpmkyu.bkt.clouddn.com/wuhongshan/md/FileList.png&quot; alt=&quot;FileList&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;3file对象&quot;&gt;3.File对象&lt;/h3&gt;

&lt;p&gt;继承自Blob对象，指向一个具体的文件。比Blob对象多了name（名称）、lastModifiedData（最后修改时间）属性。即为FileList数组中的每一项实例。&lt;/p&gt;

&lt;h3 id=&quot;4filerender对象&quot;&gt;4.FileRender对象&lt;/h3&gt;

&lt;p&gt;用来读取文件里的数据。
	4.1 &lt;code class=&quot;highlighter-rouge&quot;&gt;readAsBinaryString(Blob)&lt;/code&gt; 传入一个Blob对象，然后读取数据的结果作为二进制字符串的形式放到FileReader的result属性中。
	4.2 &lt;code class=&quot;highlighter-rouge&quot;&gt;readAsText(Blob, optional DOMString encoding)&lt;/code&gt; 第一个参数传入Blog对象，然后第二个参数传入编码格式，异步将数据读取成功后放到result属性中，读取的内容是普通的文本字符串的形式
	4.3 &lt;code class=&quot;highlighter-rouge&quot;&gt;readAsDataURL(Blob blob)&lt;/code&gt; 传入一个Blob对象，读取内容可以做为URL属性，也就是说可以将一个图片的结果指向给一个img的src属性。&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://od6qpmkyu.bkt.clouddn.com/wuhongshan/md/readAsDataURL.png&quot; alt=&quot;relust属性&quot; /&gt;&lt;/p&gt;

</description>
        <pubDate>Tue, 04 Apr 2017 00:00:00 +0000</pubDate>
        <link>https://wuhongshan.github.io//h5/c3/2017/04/04/H5%E6%96%87%E4%BB%B6%E6%93%8D%E4%BD%9CAPI/</link>
        <guid isPermaLink="true">https://wuhongshan.github.io//h5/c3/2017/04/04/H5%E6%96%87%E4%BB%B6%E6%93%8D%E4%BD%9CAPI/</guid>
        
        <category>H5/C3</category>
        
        
        <category>H5/C3</category>
        
      </item>
    
      <item>
        <title>h5文件操作API</title>
        <description>&lt;h2 id=&quot;关于文件操作的几个重要js对象&quot;&gt;关于文件操作的几个重要JS对象&lt;/h2&gt;

&lt;h3 id=&quot;1blob对象&quot;&gt;1.Blob对象&lt;/h3&gt;

&lt;p&gt;Blob是原始数据对象，提供了slice方法（获取某块数据），size（数据大小）、type（数据MIME类型）属性。&lt;/p&gt;

&lt;h3 id=&quot;2filelist对象&quot;&gt;2.FileList对象&lt;/h3&gt;

&lt;p&gt;File对象的集合。&lt;/p&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;file&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;File&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;fileList&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;#File&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;files&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;变量fileList即为FileList对象。&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://od6qpmkyu.bkt.clouddn.com/wuhongshan/md/FileList.png&quot; alt=&quot;FileList&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;3file对象&quot;&gt;3.File对象&lt;/h3&gt;

&lt;p&gt;继承自Blob对象，指向一个具体的文件。比Blob对象多了name（名称）、lastModifiedData（最后修改时间）属性。即为FileList数组中的每一项实例。&lt;/p&gt;

&lt;h3 id=&quot;4filerender对象&quot;&gt;4.FileRender对象&lt;/h3&gt;

&lt;p&gt;用来读取文件里的数据。&lt;/p&gt;

&lt;p&gt;4.1 &lt;code class=&quot;highlighter-rouge&quot;&gt;readAsBinaryString(Blob)&lt;/code&gt; 传入一个Blob对象，然后读取数据的结果作为二进制字符串的形式放到FileReader的result属性中。&lt;/p&gt;

&lt;p&gt;4.2 &lt;code class=&quot;highlighter-rouge&quot;&gt;readAsText(Blob, optional DOMString encoding)&lt;/code&gt; 第一个参数传入Blog对象，然后第二个参数传入编码格式，异步将数据读取成功后放到result属性中，读取的内容是普通的文本字符串的形式。&lt;/p&gt;

&lt;p&gt;4.3 &lt;code class=&quot;highlighter-rouge&quot;&gt;readAsDataURL(Blob blob)&lt;/code&gt; 传入一个Blob对象，读取内容可以做为URL属性，也就是说可以将一个图片的结果指向给一个img的src属性。&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://od6qpmkyu.bkt.clouddn.com/wuhongshan/md/readAsDataURL.png&quot; alt=&quot;relust属性&quot; /&gt;&lt;/p&gt;

</description>
        <pubDate>Mon, 13 Mar 2017 00:00:00 +0000</pubDate>
        <link>https://wuhongshan.github.io//%E5%8A%9F%E8%83%BD/2017/03/13/h5%E6%96%87%E4%BB%B6%E6%93%8D%E4%BD%9CAPI/</link>
        <guid isPermaLink="true">https://wuhongshan.github.io//%E5%8A%9F%E8%83%BD/2017/03/13/h5%E6%96%87%E4%BB%B6%E6%93%8D%E4%BD%9CAPI/</guid>
        
        <category>功能</category>
        
        
        <category>功能</category>
        
      </item>
    
      <item>
        <title>画布与图片</title>
        <description>&lt;h3 id=&quot;将图片填充至画布&quot;&gt;将图片填充至画布&lt;/h3&gt;

&lt;p&gt;drawImage()&lt;/p&gt;

&lt;h3 id=&quot;将画布生成图片&quot;&gt;将画布生成图片&lt;/h3&gt;

&lt;p&gt;canvas.toDataURL()&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;drawCanvas&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;canvas&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'canvas'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;canvas&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;canvas&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;canvas&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;getContext&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'2d'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;drawImage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;canvas&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;canvasToImg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;canvas&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;canvas&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;toDataURL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'image/png'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</description>
        <pubDate>Wed, 08 Mar 2017 00:00:00 +0000</pubDate>
        <link>https://wuhongshan.github.io//%E5%8A%9F%E8%83%BD/2017/03/08/%E7%94%BB%E5%B8%83%E4%B8%8E%E5%9B%BE%E7%89%87/</link>
        <guid isPermaLink="true">https://wuhongshan.github.io//%E5%8A%9F%E8%83%BD/2017/03/08/%E7%94%BB%E5%B8%83%E4%B8%8E%E5%9B%BE%E7%89%87/</guid>
        
        <category>功能</category>
        
        
        <category>功能</category>
        
      </item>
    
  </channel>
</rss>
