-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatom.xml
88 lines (48 loc) · 34.9 KB
/
atom.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Hexo</title>
<link href="/atom.xml" rel="self"/>
<link href="http://yoursite.com/"/>
<updated>2018-09-12T08:43:30.896Z</updated>
<id>http://yoursite.com/</id>
<author>
<name>John Doe</name>
</author>
<generator uri="http://hexo.io/">Hexo</generator>
<entry>
<title>js深拷贝与浅拷贝</title>
<link href="http://yoursite.com/2018/09/12/js%E6%B7%B1%E6%8B%B7%E8%B4%9D%E4%B8%8E%E6%B5%85%E6%8B%B7%E8%B4%9D/"/>
<id>http://yoursite.com/2018/09/12/js深拷贝与浅拷贝/</id>
<published>2018-09-12T08:14:24.000Z</published>
<updated>2018-09-12T08:43:30.896Z</updated>
<content type="html"><![CDATA[<h3 id="一、数据类型"><a href="#一、数据类型" class="headerlink" title="一、数据类型"></a>一、数据类型</h3><h4 id="数据分为基本数据类型-String-Number-boolean-Null-Undefined,Symbol-和对象数据类型。"><a href="#数据分为基本数据类型-String-Number-boolean-Null-Undefined,Symbol-和对象数据类型。" class="headerlink" title="数据分为基本数据类型(String, Number, boolean, Null, Undefined,Symbol)和对象数据类型。"></a>数据分为基本数据类型(String, Number, boolean, Null, Undefined,Symbol)和对象数据类型。</h4><ul><li>基本数据类型的特点:直接存储在栈(stack)中的数据</li><li>对象数据类型的特点:存储的是该对象在栈中引用,真实的数据存放在堆内存里。</li></ul><h3 id="二、深拷贝与浅拷贝"><a href="#二、深拷贝与浅拷贝" class="headerlink" title="二、深拷贝与浅拷贝"></a>二、深拷贝与浅拷贝</h3><p>深拷贝和浅拷贝是只针对Object和Array这样的对象数据类型的。</p><p>深拷贝和浅拷贝的示意图大致如下:</p><p><img src="/2018/09/12/js深拷贝与浅拷贝/164e6856d76ff161.webp" alt="img"></p><p>浅拷贝只复制指向某个对象的指针,而不复制对象本身,新旧对象还是共享同一块内存。但深拷贝会另外创造一个一模一样的对象,新对象跟原对象不共享内存,修改新对象不会改到原对象。 </p><h3 id="三、浅拷贝的实现方式"><a href="#三、浅拷贝的实现方式" class="headerlink" title="三、浅拷贝的实现方式"></a>三、浅拷贝的实现方式</h3><p><strong>1.直接赋值一个变量</strong></p><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> obj = {<span class="attr">username</span>: <span class="string">'kobe'</span>, <span class="attr">age</span>: <span class="number">39</span>, <span class="attr">sex</span>: {<span class="attr">option1</span>: <span class="string">'男'</span>, <span class="attr">option2</span>: <span class="string">'女'</span>}};</span><br><span class="line"><span class="keyword">let</span> obj1 = obj;</span><br><span class="line">obj1.sex.option1 = <span class="string">'不男不女'</span>; <span class="comment">// 修改复制的对象会影响原对象</span></span><br></pre></td></tr></table></figure><p><strong>2.Object.assign()</strong></p><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> obj = {</span><br><span class="line"> username: <span class="string">'kobe'</span></span><br><span class="line"> };</span><br><span class="line"><span class="keyword">let</span> obj2 = <span class="built_in">Object</span>.assign(obj);</span><br><span class="line">obj2.username = <span class="string">'wade'</span>;</span><br><span class="line"><span class="built_in">console</span>.log(obj);<span class="comment">//{username: "wade"}</span></span><br></pre></td></tr></table></figure><p><strong>3.Array.prototype.concat()</strong></p><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> arr = [<span class="number">1</span>, <span class="number">3</span>, {</span><br><span class="line"> username: <span class="string">'kobe'</span></span><br><span class="line"> }];</span><br><span class="line"><span class="keyword">let</span> arr2=arr.concat(); </span><br><span class="line">arr2[<span class="number">2</span>].username = <span class="string">'wade'</span>;</span><br></pre></td></tr></table></figure><p>修改新对象会改到原对象。</p><p><strong>关于Array的slice方法不修改原数组,只会返回一个浅复制了原数组中的元素的一个新数组。</strong></p><p>原数组的元素会按照下述规则拷贝:</p><ul><li>如果该元素是个对象引用(不是实际的对象),slice 会拷贝这个对象引用到新的数组里。两个对象引用都引用了同一个对象。如果被引用的对象发生改变,则新的和原来的数组中的这个元素也会发生改变。</li><li>对于字符串、数字及布尔值来说(不是 String、Number 或者 Boolean 对象),slice 会拷贝这些值到新的数组里。在别的数组里修改这些字符串或数字或是布尔值,将不会影响另一个数组。</li></ul><h3 id="四、深拷贝的实现方式"><a href="#四、深拷贝的实现方式" class="headerlink" title="四、深拷贝的实现方式"></a>四、深拷贝的实现方式</h3><p><strong>1.JSON.parse(JSON.stringify())</strong></p><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> arr = [<span class="number">1</span>, <span class="number">3</span>, {</span><br><span class="line"> username: <span class="string">' kobe'</span></span><br><span class="line">}];</span><br><span class="line"><span class="keyword">let</span> arr4 = <span class="built_in">JSON</span>.parse(<span class="built_in">JSON</span>.stringify(arr));</span><br><span class="line">arr4[<span class="number">2</span>].username = <span class="string">'duncan'</span>;</span><br></pre></td></tr></table></figure><p><strong>这种方法虽然可以实现数组或对象深拷贝,但不能处理函数等一些其他情况也可以通过JSON.stringify()方法第二个参数进行判断处理。</strong></p><p><strong>2.递归</strong></p><p>递归方法实现深度克隆原理:<strong>遍历对象、数组直到里边都是基本数据类型,然后再去复制,就是深度拷贝</strong></p><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">clone</span>(<span class="params">obj</span>) </span>{</span><br><span class="line"> <span class="keyword">var</span> o;</span><br><span class="line"> <span class="keyword">switch</span> (<span class="keyword">typeof</span> obj) {</span><br><span class="line"> <span class="keyword">case</span> <span class="string">"undefined"</span>:</span><br><span class="line"> <span class="keyword">break</span>;</span><br><span class="line"> <span class="keyword">case</span> <span class="string">"string"</span>:</span><br><span class="line"> o = obj + <span class="string">""</span>;</span><br><span class="line"> <span class="keyword">break</span>;</span><br><span class="line"> <span class="keyword">case</span> <span class="string">"number"</span>:</span><br><span class="line"> o = obj - <span class="number">0</span>;</span><br><span class="line"> <span class="keyword">break</span>;</span><br><span class="line"> <span class="keyword">case</span> <span class="string">"boolean"</span>:</span><br><span class="line"> o = obj;</span><br><span class="line"> <span class="keyword">break</span>;</span><br><span class="line"> <span class="keyword">case</span> <span class="string">"object"</span>: <span class="comment">// object 分为两种情况 对象(Object)或数组(Array)</span></span><br><span class="line"> <span class="keyword">if</span> (obj === <span class="literal">null</span>) {</span><br><span class="line"> o = <span class="literal">null</span>;</span><br><span class="line"> } <span class="keyword">else</span> {</span><br><span class="line"> <span class="keyword">if</span> (<span class="built_in">Object</span>.prototype.toString.call(obj).slice(<span class="number">8</span>, <span class="number">-1</span>) === <span class="string">"Array"</span>) {</span><br><span class="line"> o = [];</span><br><span class="line"> <span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span>; i < obj.length; i++) {</span><br><span class="line"> o.push(clone(obj[i]));</span><br><span class="line"> }</span><br><span class="line"> } <span class="keyword">else</span> {</span><br><span class="line"> o = {};</span><br><span class="line"> <span class="keyword">for</span> (<span class="keyword">var</span> k <span class="keyword">in</span> obj) {</span><br><span class="line"> o[k] = clone(obj[k]);</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">break</span>;</span><br><span class="line"> <span class="keyword">default</span>:</span><br><span class="line"> o = obj;</span><br><span class="line"> <span class="keyword">break</span>;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">return</span> o;</span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>参考文档:</p><p><a href="https://blog.csdn.net/weixin_39927080/article/details/79206320" target="_blank" rel="noopener">https://blog.csdn.net/weixin_39927080/article/details/79206320</a></p><p><a href="https://juejin.im/post/5b5dcf8351882519790c9a2e" target="_blank" rel="noopener">https://juejin.im/post/5b5dcf8351882519790c9a2e</a></p>]]></content>
<summary type="html">
<h3 id="一、数据类型"><a href="#一、数据类型" class="headerlink" title="一、数据类型"></a>一、数据类型</h3><h4 id="数据分为基本数据类型-String-Number-boolean-Null-Undefined,S
</summary>
<category term="JavaScript" scheme="http://yoursite.com/tags/JavaScript/"/>
</entry>
<entry>
<title>在线视频播放App</title>
<link href="http://yoursite.com/2018/07/15/%E5%9C%A8%E7%BA%BF%E8%A7%86%E9%A2%91%E6%92%AD%E6%94%BEApp/"/>
<id>http://yoursite.com/2018/07/15/在线视频播放App/</id>
<published>2018-07-15T01:07:48.000Z</published>
<updated>2018-08-21T09:34:10.639Z</updated>
<content type="html"><![CDATA[<p>此app采用Hybrid模式开发,兼具“Native App良好用户交互体验的优势”和“Web App跨平台开发的优势”。使用vue框架,vuex做响应式状态存储,并使用cordova提供与手机交互的API。项目地址<a href="https://github.com/dongcer/video-app" target="_blank" rel="noopener">https://github.com/dongcer/video-app</a></p><h1 id="开发环境搭建"><a href="#开发环境搭建" class="headerlink" title="开发环境搭建"></a>开发环境搭建</h1><h2 id="vue安装"><a href="#vue安装" class="headerlink" title="vue安装"></a>vue安装</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install vue</span><br></pre></td></tr></table></figure><h2 id="安装vue-cli脚手架构建工具"><a href="#安装vue-cli脚手架构建工具" class="headerlink" title="安装vue-cli脚手架构建工具"></a>安装vue-cli脚手架构建工具</h2><p>vue-cli 提供一个官方命令行工具,可用于快速搭建大型单页应用。该工具提供开箱即用的构建工具配置,带来现代化的前端开发流程。只需几分钟即可创建并启动一个带热重载、保存时静态检查以及可用于生产环境的构建配置的项目:</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install --global vue-cli</span><br></pre></td></tr></table></figure><h2 id="创建一个基于-webpack-模板的新项目"><a href="#创建一个基于-webpack-模板的新项目" class="headerlink" title="创建一个基于 webpack 模板的新项目"></a>创建一个基于 webpack 模板的新项目</h2><p>初始化一个新项目,project-name为项目文件名称</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vue init webpack project-name</span><br></pre></td></tr></table></figure><p>运行初始化命令的时候回让用户输入几个基本的选项,如项目名称,描述,作者等信息,如果不想填直接回车默认就好。之后运行:</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">npm install </span><br><span class="line">OR</span><br><span class="line">yarn install</span><br></pre></td></tr></table></figure><p> 看你初始化时的选择使用的哪种方式,之后运行测试</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm run dev</span><br></pre></td></tr></table></figure><p>运行结果<br><img src="/2018/07/15/在线视频播放App/vue.png" alt="vue"></p><h2 id="Cordova-部分"><a href="#Cordova-部分" class="headerlink" title="Cordova 部分"></a>Cordova 部分</h2><ol><li><p>安装 Cordova CLI</p><p><code>npm install -g cordova</code></p></li><li><p>找一个空目录,比如parent,在其下打开 Power Shell,建立一个 App</p><p><code>cordova create clocation com.example.hello AppName</code></p><p>其中,clocation 为项目所在文件夹名称,‘com.example.hello’ 为 App 包名,AppName 为 App 为项目打包后在移动平台上显示的应用名称。</p></li><li><p>进入项目路径</p><p><code>cd clocation</code></p></li><li><p>添加 App 运行平台</p><p><code>cordova platform add android</code></p><p>其中,android 为本次所用到的移动应用平台,官方支持的平台列表如下</p><ul><li>Android</li><li>iOS</li><li>Windows (8.1, Phone 8.1, UWP - Windows 10)</li><li>Blackberry10</li><li>Ubuntu</li><li>Browser</li></ul></li><li><p>检查项目环境依赖</p><p><code>cordova requirements</code></p><p>正常的话,结果应该是这样子的</p><blockquote><p>Requirements check results for android:<br>Java JDK: installed 1.8.0<br>Android SDK: installed true<br>Android target: installed android-<strong><strong><br>Gradle: installed </strong></strong>\bin\gradle</p></blockquote><p>如果不正常,提示 XX 未安装的话,请看第三章节。</p></li><li><p>使用 Cordova 自带的前端项目运行 App(此过程自动使用系统自带签名)</p><p><code>cordova run android --release</code> 不可被调试的版本</p><p><code>cordova run android --debug</code> 可被调试的版本</p><p>这个命令会自动打包 Apk 并使用系统自带签名去签名,然后自动通过 adb 命令将安装包发送到手机上,接着自动帮你启动手机上的 App,呈现到你的眼前,它现在应该长这样。</p><p><img src="http://172.16.25.249:4999/Public/Uploads/2018-02-01/5a726474b7f48.png" alt=""></p><p>注:手机要开启 usb 调试然后链连接到电脑,并保证当前无其他软件占用手机调试端口。否则报错。</p><p>注:此过程也可指定自己的签名,命令:</p><figure class="highlight plain"><figcaption><span>run android --release -- --keystore</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">```cordova run android --debug -- --keystore=../my-release-key.keystore --storePassword=password --alias=alias_name --password=password</span><br></pre></td></tr></table></figure></li></ol><table><thead><tr><th style="text-align:left">参数</th><th style="text-align:left">标志</th><th style="text-align:left">描述</th></tr></thead><tbody><tr><td style="text-align:left">Keystore</td><td style="text-align:left"><code>--keystore</code></td><td style="text-align:left">keystore的二进制文件路径</td></tr><tr><td style="text-align:left">Keystore Password</td><td style="text-align:left"><code>--storePassword</code></td><td style="text-align:left">keystore的存储密钥</td></tr><tr><td style="text-align:left">Alias</td><td style="text-align:left"><code>--alias</code></td><td style="text-align:left">keystore的别称</td></tr><tr><td style="text-align:left">Password</td><td style="text-align:left"><code>--password</code></td><td style="text-align:left">keystore的密码</td></tr></tbody></table><ol start="7"><li><p>使用 Cordova 自带的前端项目构建 App(此过程需要自己手动进行签名)</p><p><code>cordova build android --release</code> 不可被调试的版本</p><p><code>cordova build android --debug</code> 可被调试的版本</p><p>注:此命令运行后最终会输出编译出来的 Apk 路径,要留意。</p><p>注:此命令也可参考步骤6来签名</p></li></ol><h2 id="Vue-js-部分"><a href="#Vue-js-部分" class="headerlink" title="Vue.js 部分"></a>Vue.js 部分</h2><ol><li><p>回到父目录,并新建 Vue.js 项目并完成初始化</p><p><code>cd .. && vue init webpack vlocation</code></p></li><li><p>添加 vue-cordova 依赖</p><p><code>npm install vue-cordova --save</code></p></li><li><p>进入项目目录并对 config 文件下的 index.js 做如下修改</p><p>原:</p><figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">build: {</span><br><span class="line"> index: path.resolve(__dirname, '../dist/index.html'),</span><br><span class="line"> assetsRoot: path.resolve(__dirname, '../dist'),</span><br><span class="line"> assetsSubDirectory: './static',</span><br><span class="line"> assetsPublicPath: './',</span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>改为:</p><figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">build: {</span><br><span class="line"> index: path.resolve(__dirname, '../../cordova/www/index.html'),</span><br><span class="line"> assetsRoot: path.resolve(__dirname, '../../cordova/www'),</span><br><span class="line"> assetsSubDirectory: '',</span><br><span class="line"> assetsPublicPath: './',</span><br><span class="line">}</span><br></pre></td></tr></table></figure></li><li><p>给 src 目录下的 main.js 添加如下语句</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">import VueCordova from 'vue-cordova';</span><br><span class="line">Vue.use(VueCordova);</span><br><span class="line">if (window.location.protocol === 'file:' || window.location.port === '3000') {</span><br><span class="line"> let cordovaScript = document.createElement('script');</span><br><span class="line"> cordovaScript.setAttribute('type', 'text/javascript');</span><br><span class="line"> cordovaScript.setAttribute('src', 'cordova.js');</span><br><span class="line"> document.body.appendChild(cordovaScript);</span><br><span class="line">}</span><br></pre></td></tr></table></figure></li><li><p>打包 Vue.js 项目</p><p><code>npm run build</code></p></li><li><p>打包之后,回到 clocation 目录,构建并运行 App</p><p><code>cd ..\clocation && cordova run android</code></p><p>它应该是这样的</p><p><img src="http://172.16.25.249:4999/Public/Uploads/2018-02-01/5a72644d3c087.png" alt=""></p></li></ol><h2 id="Android-环境变量"><a href="#Android-环境变量" class="headerlink" title="Android 环境变量"></a>Android 环境变量</h2><ol><li>下载 <a href="https://developer.android.com/studio/index.html?hl=zh-cn" target="_blank" rel="noopener">Android Studio</a>(约700M),然后打开它下载一系列环境依赖,<img src="http://172.16.25.249:4999/Public/Uploads/2018-02-01/5a72642dd3e17.png" alt="">这个过程需要 ‘Crossing the Great Firewall’ </li><li>新建系统环境变量 ANDROID_HOME,指向上图的 Android SDK Location,并将其目录下的 platform-tools 和 tools 添加到 Path 变量中。</li><li>下载 <a href="https://gradle.org/install/" target="_blank" rel="noopener">Gradle</a>,解压,并配置环境变量</li></ol><h2 id="Apk签名-新"><a href="#Apk签名-新" class="headerlink" title="Apk签名(新)"></a>Apk签名(新)</h2><ol><li><p>首先使用 <a href="https://docs.oracle.com/javase/8/docs/technotes/tools/unix/keytool.html" target="_blank" rel="noopener">keytool</a> 生成一个私钥</p><p><code>keytool -genkey -v -keystore my-release-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias my-alias</code></p></li><li><p>使用 <a href="https://developer.android.com/studio/command-line/zipalign.html?hl=zh-cn" target="_blank" rel="noopener">zipalign</a> 对齐未签署的 APK:</p><p><code>zipalign -v -p 4 my-app-unsigned.apk my-app-unsigned-aligned.apk</code></p><p>zipalign 可以确保所有未压缩的数据的开头均相对于文件开头部分执行特定的字节对齐,这样可减少应用消耗的 RAM 量</p></li><li><p>通过 <a href="https://developer.android.com/studio/command-line/apksigner.html?hl=zh-cn" target="_blank" rel="noopener">apksigner</a> 使用您的私钥签署 APK:</p><p><code>apksigner sign --ks my-release-key.jks --out my-app-release.apk my-app-unsigned-aligned.apk</code></p></li><li><p>验证您的 APK 是否已签署:</p><p><code>apksigner verify my-app-release.apk</code></p></li></ol><h2 id="给-Cordova-添加插件并在-Vue-js-中使用"><a href="#给-Cordova-添加插件并在-Vue-js-中使用" class="headerlink" title="给 Cordova 添加插件并在 Vue.js 中使用"></a>给 Cordova 添加插件并在 Vue.js 中使用</h2><p> vue-cordova 默认只支持如下4个 cordova 插件(‘cordova-plugin-camera’,’cordova-plugin-device’,’cordova-plugin-geolocation’,’cordova-plugin-contacts’),要想添加其他插件的话要经过一些步骤。</p><ol><li><p>在 cordova 项目下添加插件,以 cordova-plugin-inappbrowser 为例</p><p><code>cordova plugin add cordova-plugin-inappbrowser --save</code></p></li><li><p>修改 Vue 项目中的 node_modules 文件夹里的 vue-cordova 中的 index.js</p><p>先修改 pluginsList 变量,在最后添加 cordova-plugin-inappbrowser</p><p><img src="http://172.16.25.249:4999/Public/Uploads/2018-02-01/5a7264998e470.png" alt=""></p><p>再修改 map 变量,仿照已有做如下添加</p><p><img src="http://172.16.25.249:4999/Public/Uploads/2018-02-01/5a7264a979dbe.png" alt=""></p><p>最后在末尾仿照前面的添加这样一个函数</p><p><img src="http://172.16.25.249:4999/Public/Uploads/2018-02-01/5a7264b9bd09a.png" alt=""></p></li><li><p>最后,在前端项目里,就可以拿到 Vue.cordova 对象了,这个对象里包含了当前安装插件的对象。</p></li></ol><h2 id="Cordova-常用命令"><a href="#Cordova-常用命令" class="headerlink" title="Cordova 常用命令"></a>Cordova 常用命令</h2><ol><li><p>Cordova Command-line-interface (CLI) Reference</p><p><code>cordova <command> [options] -- [platformOpts]</code></p></li></ol><table><thead><tr><th>Command</th><th>Description</th></tr></thead><tbody><tr><td>create</td><td>Create a project</td></tr><tr><td>help</td><td>Get help for a command</td></tr><tr><td>info</td><td>Generate project information</td></tr><tr><td>requirements</td><td>Checks and print out all the installation requirements for platforms specified</td></tr><tr><td>platform</td><td>Manage project platforms</td></tr><tr><td>plugin</td><td>Manage project plugins</td></tr><tr><td>prepare</td><td>Copy files into platform(s) for building</td></tr><tr><td>compile</td><td>Build platform(s)</td></tr><tr><td>clean</td><td>Cleanup project from build artifacts</td></tr><tr><td>run</td><td>Run project (including prepare && compile)</td></tr><tr><td>serve</td><td>Run project with a local webserver (including prepare)</td></tr></tbody></table><table><thead><tr><th>Option</th><th>Description</th></tr></thead><tbody><tr><td>-d or –verbose</td><td>Pipe out more verbose output to your shell. You can also subscribe to <code>log</code> and <code>warn</code> events if you are consuming <code>cordova-cli</code> as a node module by calling <code>cordova.on('log', function() {})</code> or <code>cordova.on('warn', function() {})</code>.</td></tr><tr><td>-v or –version</td><td>Print out the version of your <code>cordova-cli</code> install.</td></tr><tr><td>–no-update-notifier</td><td>Will disable updates check. Alternatively set <code>"optOut": true</code> in <code>~/.config/configstore/update-notifier-cordova.json</code> or set <code>NO_UPDATE_NOTIFIER</code> environment variable with any value (see details in <a href="https://www.npmjs.com/package/update-notifier#user-settings" target="_blank" rel="noopener">update-notifier docs</a>).</td></tr><tr><td>–nohooks</td><td>Suppress executing hooks (taking RegExp hook patterns as parameters)</td></tr></tbody></table><ol start="2"><li><p>cordova create command</p><p><code>cordova create path [id [name [config]]] [options]</code></p></li></ol><table><thead><tr><th>Value</th><th>Description</th></tr></thead><tbody><tr><td>path</td><td>Directory which should not already exist. Cordova will create this directory. For more details on the directory structure, see below.</td></tr><tr><td>id</td><td><em>Default</em>: <code>io.cordova.hellocordova</code> Reverse domain-style identifier that maps to <code>id</code> attirbute of <code>widget</code> element in <code>config.xml</code>. This can be changed but there may be code generated using this value, such as Java package names. It is recommended that you select an appropriate value.</td></tr><tr><td>name</td><td><em>Default</em>: <code>HelloCordova</code> Application’s display title that maps <code>name</code> element in <code>config.xml</code> file. This can be changed but there may be code generated using this value, such as Java class names. The default value is <code>HelloCordova</code>, but it is recommended that you select an appropriate value.</td></tr><tr><td>config</td><td>JSON string whose key/values will be included in <code><path></code>/.cordova/config.json</td></tr></tbody></table><table><thead><tr><th>Option</th><th>Description</th></tr></thead><tbody><tr><td>–template</td><td>Use a custom template located locally, in NPM, or GitHub.</td></tr><tr><td>–copy-from\</td><td>–src</td></tr><tr><td>–link-to</td><td>Symlink to specified <code>www</code> directory without creating a copy.</td></tr></tbody></table><ol start="3"><li><p>cordova platform command</p><p><code>cordova platform command <platform-spec></code></p></li></ol><table><thead><tr><th>command</th><th>Description</th></tr></thead><tbody><tr><td>add</td><td>Add specified platforms</td></tr><tr><td>remove</td><td>Remove specified platforms</td></tr><tr><td>update</td><td>Update specified platforms</td></tr><tr><td>list</td><td>List all installed and available platforms</td></tr><tr><td>check</td><td>List platforms which can be updated by <code>cordova-cli platform update</code></td></tr><tr><td>save</td><td>Save <code><platform-spec></code> of all platforms added to config.xml</td></tr></tbody></table><p> 注:<platform-spec> : platform[@version] | path | url[#commit-ish]</platform-spec></p><table><thead><tr><th>Value</th><th>Description</th></tr></thead><tbody><tr><td>platform</td><td>Platform name e.g. android, ios, windows etc. to be added to the project. Every release of cordova CLI pins a version for each platform. When no version is specified this version is used to add the platform.</td></tr><tr><td>version</td><td>Major.minor.patch version specifier using semver</td></tr><tr><td>path</td><td>Path to a directory or tarball containing a platform</td></tr><tr><td>url</td><td>URL to a git repository or tarball containing a platform</td></tr><tr><td>commit-ish</td><td>Commit/tag/branch reference. If none is specified, ‘master’ is used</td></tr></tbody></table><p> Supported Platforms</p><ul><li>Android</li><li>iOS</li><li>Windows (8.1, Phone 8.1, UWP - Windows 10)</li><li>Blackberry10</li><li>Ubuntu</li><li>Browser</li></ul><ol start="4"><li>cordova plugin command</li></ol>]]></content>
<summary type="html">
<p>此app采用Hybrid模式开发,兼具“Native App良好用户交互体验的优势”和“Web App跨平台开发的优势”。使用vue框架,vuex做响应式状态存储,并使用cordova提供与手机交互的API。项目地址<a href="https://github.com/d
</summary>
<category term="vue" scheme="http://yoursite.com/tags/vue/"/>
<category term="cordova" scheme="http://yoursite.com/tags/cordova/"/>
</entry>
<entry>
<title>Hello World</title>
<link href="http://yoursite.com/2017/12/24/hello-world/"/>
<id>http://yoursite.com/2017/12/24/hello-world/</id>
<published>2017-12-24T15:29:53.000Z</published>
<updated>2018-08-19T10:09:14.951Z</updated>
<content type="html"><![CDATA[<p>Welcome to <a href="https://hexo.io/" target="_blank" rel="noopener">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/" target="_blank" rel="noopener">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="https://hexo.io/docs/troubleshooting.html" target="_blank" rel="noopener">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues" target="_blank" rel="noopener">GitHub</a>.</p><h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo new <span class="string">"My New Post"</span></span><br></pre></td></tr></table></figure><p>More info: <a href="https://hexo.io/docs/writing.html" target="_blank" rel="noopener">Writing</a></p><h3 id="Run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure><p>More info: <a href="https://hexo.io/docs/server.html" target="_blank" rel="noopener">Server</a></p><h3 id="Generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure><p>More info: <a href="https://hexo.io/docs/generating.html" target="_blank" rel="noopener">Generating</a></p><h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure><p>More info: <a href="https://hexo.io/docs/deployment.html" target="_blank" rel="noopener">Deployment</a></p>]]></content>
<summary type="html">
<p>Welcome to <a href="https://hexo.io/" target="_blank" rel="noopener">Hexo</a>! This is your very first post. Check <a href="https://hexo.
</summary>
</entry>
</feed>