首页 \ 问答 \ 如何添加和使用Cordova插件(How to add and work with Cordova plugins)

如何添加和使用Cordova插件(How to add and work with Cordova plugins)

我如何在我的Cordova应用程序中添加插件? 我找不到任何例子。 我正在尝试在nodejs提示符下安装和添加插件: npm i PLUGIN_NAMEcordova plugin add PLUGIN_NAME 。 之后,我正在尝试在标签<script></script> index.html文件中为此插件编写代码,并且我在控制台中有很多错误: Uncaught ReferenceError: cordova is not defined(…)或另一个。 我读过许多关于这个的文档,我知道我需要将任何有关插件的记录添加到config.xml文件中。 但我怎么能做到这一点? 你能帮我解决这个问题吗?


How I can add plugins in my Cordova app? I can't find any examples. I'm trying to install and add plugins in nodejs prompt: npm i PLUGIN_NAME and cordova plugin add PLUGIN_NAME. After that, I'm trying to write a code for this plugin in my index.html file in tag <script></script> and I have many errors in console like that: Uncaught ReferenceError: cordova is not defined(…) or another. I did read many documentation about that and I know that I need to add any records about plugins to config.xml file. But how I can do it? Can you help me with this trouble?


原文:https://stackoverflow.com/questions/40647460
更新时间:2022-04-22 13:04

最满意答案

Node.js是事件驱动的,这意味着大部分函数是异步的。 execute函数不会返回任何值,因为“返回”值位于声明为第一个参数的匿名函数中,只有在查询已执行并且数据库已返回值时才会调用该函数。 所以你的result变量不包含任何值,因为没有任何东西可以返回。

** 编辑 **

即使在编辑之后,记录变量result rows也会向其分配rows 之前执行,因为匿名函数仅在稍后执行,即查询完成时。


Node.js is event driven, meaning that most of the functions are asynchronous. The execute function does not return any value, because the "returned" value is in the anonymous function declared as your first argument, which function will be called only when the query has been executed and a value has been returned by the database. So your result variable does not contain any value, because there's nothing to return yet.

** EDIT **

Even after your edit, the line where you log the variable result is executed before you assign rows to it, because the anonymous function is only executed later, when the query is completed.

相关问答

更多
  • 你将fridge作为参数传递,如果它将成为局部变量。 要使用全球fridge你应该这样做: FRIDGE = {"cheese": 10, "milk": 11, "feta": 12, "cream": 21, "onion": 32, "pepper": 25} def fridge_function(): del FRIDGE["feta"] fridge_function() # you need to call it print(FRIDGE) 全局变量通常是上层变量,所以我称之 ...
  • Node.js是事件驱动的,这意味着大部分函数是异步的。 execute函数不会返回任何值,因为“返回”值位于声明为第一个参数的匿名函数中,只有在查询已执行并且数据库已返回值时才会调用该函数。 所以你的result变量不包含任何值,因为没有任何东西可以返回。 ** 编辑 ** 即使在编辑之后,记录变量result rows也会在向其分配rows 之前执行,因为匿名函数仅在稍后执行,即查询完成时。 Node.js is event driven, meaning that most of the functi ...
  • 假设 global $this_month_revenue; global $this_month_sales; global $last_month_revenue; global $last_month_sales; 是您在调用它时要传递给函数的变量。 例如: compareMonths($checkingRevenue, $this_month_revenue, $this_month_sales); function compareMonths($checkingRevenue, $val1, ...
  • 您可以使用“use”来使用父作用域中的变量: $this->getRouter()->addRoute($routing->getPath(), function() use ($routing) { // SCOPE PROBLEM: $routing is no more available if($routing->hasController()) { // Line 60 Controller::get($routing->getController(), $this ...
  • 这只是JavaScript的核心概念(特别是ECMAScript5)。 匿名函数,特别是在闭包中,不保留上下文。 你可以做这样的事情: (function() { console.log("inner func: this.foo = " + this.foo); console.log("inner func: self.foo = " + self.foo); }).call(this); 那是因为你实际上在调用这个函数。 如果您传递回调,则可以使用Function.prototy ...
  • 它会是对象的副本吗? 是。 或者可以使用移动,或者可以优化整个事物,以便在最终的编译程序中只生成一个实际对象。 但是,基本上,是的。 如果我用一个新的Object替换对象向量中的元素2,那么旧的值现在是“超出范围”并被删除了吗? 是。 顺便说一句,你正在使用不存在的元素; 要添加元素,请使用insert或push_back 。 Will it be a copy of the object? Yes. Or a move could be used instead, or the entire thing ...
  • 假设此代码的目的只是为了学习; 你创建一个匿名函数,但你仍然指的是前一个范围中的i ,所以你不要改变你最初编写的第一个代码; i仍然有最后一个值( list.length )。 为了避免这种情况,您需要在您创建的函数范围内具有i的当前值: function buildList(list) { var result = []; for (var i = 0; i < list.length; i++) { var item = 'item' + list[i]; result.pus ...
  • 它被称为变量范围和阴影: Go是使用块的词法范围: 1 - 预先声明的标识符的范围是Universe块。 2 - 在顶级(在任何函数之外)声明的表示常量,类型,变量或函数(但不是方法)的标识符的范围是包块。 3 - 导入包的包名称范围是包含导入声明的文件的文件块。 4-表示方法接收者,函数参数或结果变量的标识符的范围是函数体。 5-在函数内声明的常量或变量标识符的范围从ConstSpec或VarSpec(短变量声明的ShortVarDecl)结束开始,并在最内层包含块的末尾结束。 6-在函数内声明的类型标识 ...
  • 是的:您可以使用“使用”声明。 function a() { $c = 1; b(function() use ($c) { echo $c; }); } function b($code){ $code(); } Yes: you can use "use" statement. function a() { $c = 1; b(function() use ($c) { echo $c; }); } funct ...
  • 如果你不想要$this的值,你需要一个静态匿名函数 。 class Foo{ public function bar(){ $data = [ 'calculation' => static function(){ // $this is not defined } ]; } } 静态匿名函数没有自动绑定的$this值,并且以后不能将其他值绑定到它们。 If you don't want a value for $this, ...

相关文章

更多

最新问答

更多
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)
  • 是否可以嵌套hazelcast IMaps?(Is it possible to nest hazelcast IMaps? And whick side effects can I expect? Is it a good Idea anyway?)
  • UIViewAnimationOptionRepeat在两个动画之间暂停(UIViewAnimationOptionRepeat pausing in between two animations)
  • 在x-kendo-template中使用Razor查询(Using Razor query within x-kendo-template)
  • 在BeautifulSoup中替换文本而不转义(Replace text without escaping in BeautifulSoup)
  • 如何在存根或模拟不存在的方法时配置Rspec以引发错误?(How can I configure Rspec to raise error when stubbing or mocking non-existing methods?)
  • asp用javascript(asp with javascript)
  • “%()s”在sql查询中的含义是什么?(What does “%()s” means in sql query?)
  • 如何为其编辑的内容提供自定义UITableViewCell上下文?(How to give a custom UITableViewCell context of what it is editing?)
  • c ++十进制到二进制,然后使用操作,然后回到十进制(c++ Decimal to binary, then use operation, then back to decimal)
  • 以编程方式创建视频?(Create videos programmatically?)
  • 无法在BeautifulSoup中正确解析数据(Unable to parse data correctly in BeautifulSoup)
  • webform和mvc的区别 知乎
  • 如何使用wadl2java生成REST服务模板,其中POST / PUT方法具有参数?(How do you generate REST service template with wadl2java where POST/PUT methods have parameters?)
  • 我无法理解我的travis构建有什么问题(I am having trouble understanding what is wrong with my travis build)
  • iOS9 Scope Bar出现在Search Bar后面或旁边(iOS9 Scope Bar appears either behind or beside Search Bar)
  • 为什么开机慢上面还显示;Inetrnet,Explorer
  • 有关调用远程WCF服务的超时问题(Timeout Question about Invoking a Remote WCF Service)