cordova打印机插件:Uncaught TypeError:无法读取未定义

时间:2017-02-26 02:56:14

标签: cordova printing phonegap-plugins

我尝试下载cordova打印机插件cordova-plugin-printer 的示例,以便在我的phonegap项目中使用它。我已将相应的js放在文件夹中,当我点击inspect元素时没有错误。但是,当我单击按钮时,它会显示错误

  

未捕获的TypeError:无法读取未定义的属性'printer'       在HTMLAnchorElement.print

我已经安装了插件,但我无法让它工作。我也不确定要放入功能标签的内容。这可能是问题吗?

修改

<!DOCTYPE html>
<!--
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 -->
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
        <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
        <meta name="format-detection" content="telephone=no">
        <meta name="msapplication-tap-highlight" content="no">
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
        <link rel="stylesheet" type="text/css" href="css/index.css">
        <title>Printer Plugin</title>
    </head>
    <body>
        <div class="app">
            <h1>Printer Plugin</h1>
            <div id="deviceready" class="blink">
                <p class="event listening">Connecting to Device</p>
                <p class="event received">Device is Ready</p>
            </div>
            <div class="container">
                <a id="check" href="#" class="button grey">Check</a>
                <a id="pick" href="#" class="button grey">Pick</a>
                <a id="print" href="#" class="button orange">Print</a>
            </div>
        </div>
        <div class="copyright">
            © 2016 appPlant<br/>
            Made with <g-emoji alias="yum" fallback-src="https://assets-cdn.github.com/images/icons/emoji/unicode/1f60b.png">😋</g-emoji> from Leipzig
        </div>
        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="js/index.js"></script>
    </body>
</html>

实际上这个代码来自给出的样本,我只是尝试运行它并失败了。我认为插件无法读取

0 个答案:

没有答案