【问题标题】:Changing cordova barcode scanner default message更改科尔多瓦条码扫描仪默认消息
【发布时间】:2016-05-25 12:45:07
【问题描述】:

我正在使用 cordova 条码扫描器进行混合应用程序开发,我非常担心条码扫描器的默认消息:“将条码放在取景器矩形内进行扫描。”

如何更改默认消息?我期待与此类似: 吴科尔多瓦: $cordova条形码扫描仪 。扫描() .title('请扫描这里') //类似这样 .then(函数(barcodeData){ // 成功!条形码数据在这里 },函数(错误){ // 发生错误 });

来自cordova插件:但我不知道如何在cordovaBarcodeScanner中使用它

cordova.plugins.barcodeScanner.scan(
      function (result) {

      }, 
      function (error) {
          alert("Scanning failed: " + error);
      },
      {
          // how can i use this in above?
          "prompt" : "Place a barcode inside the scan area", 
      }
   );

【问题讨论】:

  • @JoeClay 但是cordova插件确实有这个功能。我只是不知道如何在 ngCordova 中使用它。那么你的意思是cordova插件有的东西可能在ngCordova中不可用吗?

标签: angularjs cordova ionic-framework


【解决方案1】:

要实现条形码扫描仪,请按照以下步骤操作。

第 1 步:将此 cordova plugin add https://github.com/phonegap/phonegap-plugin-barcodescanner.git 安装到您的项目中。

第 2 步:在您的 js 文件中实现此代码

$cordovaBarcodeScanner
      .scan()
      .then(function(barcodeData) {
        // Success! Barcode data is here
      }, function(error) {
        // An error occurred
      });


    // NOTE: encoding not functioning yet
    $cordovaBarcodeScanner
      .encode(BarcodeScanner.Encode.TEXT_TYPE, "http://www.nytimes.com")
      .then(function(success) {
        // Success!
      }, function(error) {
        // An error occurred
      });

  },

要了解有关 ngCordova 条形码扫描仪的更多信息,请查看website。

这里是更多信息的教程nicrobay barcode scanner。

您作为警报恢复的消息是从后端接收到的。

【讨论】:

  • 那么我该如何更改文本?
  • 扫描您收到的文本或 URL 是从后端发送后,我对此并不熟悉,但我相信您应该在后端看到您从条形码收到的文本。跨度>
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-11-09
  • 2018-06-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多