美文网首页
Codova支持小程序容器OpenApp+

Codova支持小程序容器OpenApp+

作者: linwaiwai | 来源:发表于2020-04-08 18:15 被阅读0次

自动安装

安装cordova

> npm install -g cordova
> cordova create MyApp
> cd Cordova-Demo
> cordova platform add ios
> cordova plugin add @openapplus/cordova-openapplus-plugin

编写codova插件调用函数

function onButtonClicked(){
    var CordovaOpenApplusPlugin = cordova.plugins.CordovaOpenApplusPlugin;
    CordovaOpenApplusPlugin.navigateToMiniProgram("openapplus://jsApp/Lr12JhPrE9bg7N4uoABBXY");
}
var app = {
    // Application Constructor
    initialize: function() {
        document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
    },

    // deviceready Event Handler
    //
    // Bind any cordova events here. Common events are:
    // 'pause', 'resume', etc.
    onDeviceReady: function() {
        this.receivedEvent('deviceready');
        var CordovaOpenApplusPlugin = cordova.plugins.CordovaOpenApplusPlugin;
        CordovaOpenApplusPlugin.start("oa606f78973e434c78933b869d8ba73c59","$2a$10$4bbR9ZNAhm74x3sckSLf/uPyR.E2JQvACCHP4xKtLt/OOpbJsiq9q");
        CordovaOpenApplusPlugin.enableLogging(true);

        document.querySelector('button').addEventListener('click', onButtonClicked);
    },

    // Update DOM on a Received Event
    receivedEvent: function(id) {
        var parentElement = document.getElementById(id);
        var listeningElement = parentElement.querySelector('.listening');
        var receivedElement = parentElement.querySelector('.received');

        listeningElement.setAttribute('style', 'display:none;');
        receivedElement.setAttribute('style', 'display:block;');

        console.log('Received Event: ' + id);
    }
};

app.initialize();

完整Demo下载地址

https://github.com/linwaiwai/openapplus-demo/

手动安装

下载插件

1、在Demo中找到插件下载CordovaOpenApplusPlugin
2、修改插件配置文件plugin.xml

<?xml version='1.0' encoding='utf-8'?>
<plugin id="cordova-openapplus-plugin" version="0.0.4" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
    <name>CordovaOpenApplusPlugin</name>
    <js-module name="CordovaOpenApplusPlugin" src="www/CordovaOpenApplusPlugin.js">
        <clobbers target="cordova.plugins.CordovaOpenApplusPlugin" />
    </js-module>
    <platform name="ios">
        <config-file parent="/*" target="config.xml">
            <feature name="CordovaOpenApplusPlugin">
                <param name="ios-package" value="CordovaOpenApplusPlugin" />
            </feature>
        </config-file>
        <source-file src="src/ios/CordovaOpenApplusPlugin.m" />
        <!-- <framework src="lib/OpenApplus.framework" embed="true" custom="true" /> -->
        <podspec>
          <config>
            <source url="https://github.com/CocoaPods/Specs.git"/>
          </config>
          <pods use-frameworks="true">
          <!--   <pod name="SDWebImage"  spec="3.7.5" />
            <pod name="SSZipArchive"  spec="1.6.2" />
            <pod name="SVProgressHUD"   spec="2.1.2" />
            <pod name="UMengUShare/Social/WeChat"   spec="6.3.0" />
            <pod name="MJRefresh"   spec="3.1.12" />
            <pod name="libextobjc"   spec="~> 0.4.1" />
            <pod name="AFNetworking"   spec="~> 3.2.1" /> -->
            <pod name="OpenApplus"   podspec="../../plugins/cordova-openapplus-plugin/podspec/OpenApplus.podspec" />
          </pods>
        </podspec>
    </platform>
</plugin>

<?xml version='1.0' encoding='utf-8'?>
<plugin id="cordova-openapplus-plugin" version="0.0.4" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
    <name>CordovaOpenApplusPlugin</name>
    <js-module name="CordovaOpenApplusPlugin" src="www/CordovaOpenApplusPlugin.js">
        <clobbers target="cordova.plugins.CordovaOpenApplusPlugin" />
    </js-module>
    <platform name="ios">
        <config-file parent="/*" target="config.xml">
            <feature name="CordovaOpenApplusPlugin">
                <param name="ios-package" value="CordovaOpenApplusPlugin" />
            </feature>
        </config-file>
        <source-file src="src/ios/CordovaOpenApplusPlugin.m" />
        <framework src="lib/OpenApplus.framework" embed="true" custom="true" />
        <podspec>
          <config>
            <source url="https://github.com/CocoaPods/Specs.git"/>
          </config>
          <pods use-frameworks="true">
                <pod name="SDWebImage"  spec="3.7.5" />
            <pod name="SSZipArchive"  spec="1.6.2" />
            <pod name="SVProgressHUD"   spec="2.1.2" />
            <pod name="UMengUShare/Social/WeChat"   spec="6.3.0" />
            <pod name="MJRefresh"   spec="3.1.12" />
            <pod name="libextobjc"   spec="~> 0.4.1" />
            <pod name="AFNetworking"   spec="~> 3.2.1" /> -->
          </pods>
        </podspec>
    </platform>
</plugin>

3、创建lib目录,下载OpenApplus.framework 到 lib目录下
3、cordova plugin add path/to/CordovaOpenApplusPlugin

相关文章

  • Codova支持小程序容器OpenApp+

    自动安装 安装cordova 编写codova插件调用函数 完整Demo下载地址 https://github.c...

  • OpenApp+小程序容器支持Maven

    使用gradle 详细添加位置请参考DEMO[https://github.com/linwaiwai/opena...

  • OpenApplus小程序容器

    概述 OpenApp+ 一个小程序容器,配置简单、功能完善、界面流畅、开箱即用!使用OpenApp+可以快速扩展你...

  • OpenApplus管理平台使用说明

    OpenApp+ 小程序是一款基于微信小程序标准而独立开发的产品。 开发者一方面能够把微信小程序快速迁移到自己的 ...

  • 微信小程序(四)视图组件

    小程序组件 视图容器 (一) 视图容器 了解小程序组件中的视图容器 明确小程序组件中的视图容器的用途和方法 了解不...

  • 微信小程序样式

    微信小程序view支持两种布局方式:Block和Flex。所有view默认都是block。 一、Flex容器 采用...

  • 【已失效】解决微信小程序<web-view>组件所在

    问题出现 组件是微信小程序1.6.4版本开始支持的功能,用以承载网页的容器,会自动铺满整个小程...

  • J2EE容器

    J2EE 容器的类型 J2EE 容器为 J2EE 应用程序组件提供运行时支持。J2EE 应用程序组件使用容器的协议...

  • 小程序和h5的互相跳转

    小程序到h5 wxml 小程序.js 显示h5的页面容器【emmm。。是有个容器banner_detail文件夹 ...

  • 容器安全之启用实时恢复

    描述 live-restore参数可以支持无守护程序的容器运行。它确保Docker在关闭或恢复时不会停止容器,并在...

网友评论

      本文标题:Codova支持小程序容器OpenApp+

      本文链接:https://www.haomeiwen.com/subject/wlxxmhtx.html