整合營銷服務(wù)商

          電腦端+手機端+微信端=數(shù)據(jù)同步管理

          免費咨詢熱線:

          Ionic開發(fā)(十四-2 配置文件plugin.xm

          Ionic開發(fā)(十四-2 配置文件plugin.xml詳解)

          onic開發(fā)中,cordova自定義插件之配置文件plugin.xml詳解

          <?xml version="1.0" encoding="UTF-8"?>

          <plugin

          xmlns="http://apache.org/cordova/ns/plugins/1.0"id="cordova-plugin-device"version="0.0.1">

          <engines>

          <enginename="cordova-android"version="=1.8.0"/>

          </engines>

          <name>Device</name>

          <description>Cordova Device Plugin</description>

          <license>Apache 2.0</license>

          <keywords>cordova,device</keywords>

          <js-modulesrc="www/device.js"name="device">

          <clobberstarget="device"/>

          </js-module>

          <platformname="ios">

          <config-filetarget="config.xml"parent="/*">

          <featurename="Device">

          <paramname="ios-package"value="CDVDevice"/>

          </feature>

          </config-file>

          <header-filesrc="src/ios/CDVDevice.h"/>

          <source-filesrc="src/ios/CDVDevice.m"/>

          </platform>

          </plugin>

          詳細(xì)解讀:

          1、plugin(頂級節(jié)點,最外層)

          <?xml version="1.0" encoding="UTF-8"?>

          <plugin

          xmlns="http://apache.org/cordova/ns/plugins/1.0"

          xmlns:android="http://schemas.android.com/apk/res/android"id="my-plugin-id"version="1.0.2">

          Attributes

          xmlns:插件命名空間,如果包括其他命名空間的xml文件,例如android的AndroidManifest.xml 也需要添加到plugin的頭標(biāo)簽中。

          id:npm風(fēng)格的插件標(biāo)識符

          version:插件版本號(例:0.0.1)

          2、engine/engines (二級節(jié)點)

          需要注意cordova6.1.0以上版本,推薦在package.json中指定插件依賴的platform、plugin和CLI 。

          <engines>

          <enginename="cordova-android"version="=1.8.0"/>

          </engines>

          <engines>

          <enginename="cordova"version="&gt;=1.7.0"/>

          <enginename="cordova-android"version="&gt;=1.8.0"/>

          <enginename="cordova-ios"version="&gt;=1.7.1"/>

          </engines>

          默認(rèn)支持的引擎如下:

          cordova

          cordova-plugman

          cordova-android

          cordova-ios

          cordova-blackberry10

          cordova-wp8

          cordova-windows

          cordova-osx

          windows-os

          android-sdk (returns the highest Android api level installed)

          windows-sdk (returns the native windows SDK version)

          apple-xcode (returns the xcode version)

          apple-ios (returns the highest iOS version installed)

          apple-osx (returns the OSX version)

          blackberry-ndk (returns the native blackberry SDK version)

          &gt;=1.7.1

          是模糊指定版本,>=1.7.1

          3、name(二級節(jié)點)

          <name>Foo</name>

          指定插件名稱

          4、description(二級節(jié)點)

          <description>Foo plugin description</description>

          插件描述信息

          5、author(二級節(jié)點)

          <author>Foo plugin author</author>

          插件作者

          6、keywords(二級節(jié)點)

          <keywords>foo,bar</keywords>

          插件關(guān)鍵字

          7、license(二級節(jié)點)

          <license>Apache 2.0 License</license>

          插件授權(quán)描述

          8、asset(二級節(jié)點)

          <!-- a single file, to be copied in the root directory -->

          <assetsrc="www/foo.js"target="foo.js"/>

          <!-- a directory, also to be copied in the root directory -->

          <assetsrc="www/foo"target="foo"/>

          列出將被復(fù)制到www下的文件夾和文件等資源,

          src是插件里相對plugin.xml的路徑,必須存在,否則安裝插件的時候會報錯失敗;

          target是app里相對www文件夾的路徑,如果已經(jīng)存在,那么安裝插件的時候會報錯失敗。

          可以設(shè)定多級子文件夾,同時可以重命名

          9、js-module(二級節(jié)點)(platform下子節(jié)點)

          <js-modulesrc="socket.js"name="Socket"></js-module>

          src是插件里相對plugin.xml的js文件路徑,必須存在,否則CLI安裝插件的時候會報錯失敗;

          name可以自行設(shè)定module的名稱,通常是插件的id。

          一個<js-module>對應(yīng)一個javascript文件,避免用戶不得不為每一個文件引入<script>標(biāo)簽,會自動添加。

          <js-module>可以嵌套在指定的<platform>中,用于指定平臺下的js 模塊聲明。

          例子分析:安裝插件的時候,socket.js 會被拷貝到 /www/plugins/my-plugin-id/socket.js ,同時在/www/cordova_plugins.js 中添加條目,應(yīng)用啟動加載的時候,cordova.js 通過XHR讀取每個文件并注入<script>到html中。

          Also for this example, with a plugin id of chrome-socket, the module name will be chrome-socket.Socket.

          參考:http://cordova.apache.org/docs/en/latest/plugin_ref/spec.html

          下實例中,通過切換不同開關(guān) checked 顯示不同的值,true 為打開,false 為關(guān)閉。

          HTML 代碼

          <ion-header-bar class="bar-positive">
           <h1 class="title">開關(guān)切換</h1></ion-header-bar>
           <ion-content>
           <div class="list">
           <div class="item item-divider">
           Settings </div>
           <ion-toggle ng-repeat="item in settingsList"
           ng-model="item.checked"
           ng-checked="item.checked">
           {{ item.text }} </ion-toggle>
           <div class="item">
           <!-- 使用 pre 標(biāo)簽展示效果更美觀 -->
           <div ng-bind="settingsList | json"></div>
           </div>
           <div class="item item-divider">
           Notifications </div>
           <ion-toggle ng-model="pushNotification.checked"
           ng-change="pushNotificationChange()">
           Push Notifications </ion-toggle>
           <div class="item">
           <!-- 使用 pre 標(biāo)簽展示效果更美觀 -->
           <div ng-bind="pushNotification | json"></div>
           </div>
           <ion-toggle toggle-class="toggle-assertive"
           ng-model="emailNotification"
           ng-true-value="'Subscribed'"
           ng-false-value="'Unubscribed'">
           Newsletter </ion-toggle>
           <div class="item">
           <!-- 使用 pre 標(biāo)簽展示效果更美觀 -->
           <div ng-bind="emailNotification | json"></div>
           </div>
           </div>
           </ion-content>

          由于pre標(biāo)簽沖突,實例中的 pre 已替換為 div標(biāo)簽,具體可以在"嘗試一下"中查看。

          JavaScript 代碼

          angular.module('ionicApp', ['ionic']).controller('MainCtrl', function($scope) {
           $scope.settingsList=[
           { text: "Wireless", checked: true },
           { text: "GPS", checked: false },
           { text: "Bluetooth", checked: false }
           ];
           $scope.pushNotificationChange=function() {
           console.log('Push Notification Change', $scope.pushNotification.checked);
           };
           $scope.pushNotification={ checked: true };
           $scope.emailNotification='Subscribed';
           });

          css 代碼:

          body {
           cursor: url('http://www.runoob.com/try/demo_source/finger.png'), auto;}

          效果如下所示:

          ionic 單選框操作

          ionic 手勢事件

          話不說直接上干貨



          開發(fā)語言

          Flutter Dart

          Ionic HTML,CSS,JavaScript(支持VUE React Angular)

          運行環(huán)境

          Flutter Flutter特有的引擎

          Ionic Web 瀏覽器(或者WebView)

          硬件功能訪問

          Flutter Flutter 本地接口插件庫

          Ionic Cordova 或者 Capacitor(比較成熟的插件庫)

          離線訪問

          Flutter 支持

          Ionic 支持

          App流暢度

          Flutter 和原生沒差別

          Ionic 不如原生,但是感受不出來明顯的差距

          瀏覽器端表現(xiàn)

          Flutter 有限支持

          Ionic 天生適合瀏覽器訪問

          可實現(xiàn)應(yīng)用

          Flutter 手機APP,電腦桌面軟件,瀏覽器應(yīng)用

          Ionic 手機APP,電腦桌面軟件,瀏覽器應(yīng)用,PWA


          再來一個小總結(jié):

          Ionic 因為使用的是html css js等web開發(fā)的技術(shù),所以上手容易生態(tài)繁榮,但是也因為如此,ionic開發(fā)的APP的性能,距離原生還有一段差距


          主站蜘蛛池模板: 亚洲一区二区三区偷拍女厕| 亚洲综合一区二区精品久久| 蜜桃臀无码内射一区二区三区 | 日美欧韩一区二去三区| 国产亚洲自拍一区| 日本精品少妇一区二区三区| 日韩中文字幕一区| 99久久人妻精品免费一区| 中文字幕在线观看一区二区三区| 精品国产一区二区三区久| 99精品国产高清一区二区| 国产一区二区精品| 国产精品熟女一区二区| 国产亚洲一区区二区在线| 久久久久人妻精品一区三寸蜜桃| 在线观看国产一区亚洲bd| 少妇一夜三次一区二区| 99精品一区二区三区| 国产一区二区三区免费观看在线| 日韩精品久久一区二区三区| 在线成人综合色一区| 国产手机精品一区二区| 亚洲AV无码片一区二区三区| 黑巨人与欧美精品一区| 国产午夜精品一区二区三区| 色欲综合一区二区三区| 亚洲国产精品乱码一区二区| 午夜福利一区二区三区高清视频 | 少妇无码一区二区二三区| 秋霞电影网一区二区三区| 精品国产一区二区三区| 午夜性色一区二区三区不卡视频 | 日韩一区二区三区在线精品 | 69福利视频一区二区| 亚洲爆乳精品无码一区二区三区 | 国产在线精品一区在线观看| 国产麻豆媒一区一区二区三区| 立川理惠在线播放一区| 日韩视频一区二区| 日韩在线观看一区二区三区| 精品久久一区二区三区|