【问题标题】:When i use nativescript-uuid plugin a get a error当我使用 nativescript-uuid 插件时出现错误
【发布时间】:2020-05-02 15:13:41
【问题描述】:

我收到一条错误消息:

"TypeError: SSKeychain.passwordForServiceAccount is not a function. (In 'SSKeychain.passwordForServiceAccount(appName, "incoding")', 'SSKeychain.passwordForServiceAccount' is undefined)"

当我这样做时:

const uid = require("nativescript-uuid"); var uuid = uid.getUUID(); console.log("The device UUID is " + uuid);

我只想获取用户设备的设备 ID,以便存储它。

【问题讨论】:

  • 这段代码你在哪里写的?在方法?你最好在这里展示他的完整功能。
  • 我是在mounted() {} @RalfBordé
  • 这一行const uid = require("nativescript-uuid");我在export default {上方导入
  • 您使用的是最新版本的 {N} 和插件吗?你能分享一个可以重现问题的示例项目吗?
  • 是的,我使用了最新版本的@Manoj

标签: nativescript nativescript-vue


【解决方案1】:

1) 安装:tns plugin add nativescript-uuid

2) 此代码有效:

<script>
var plugin = require("nativescript-uuid");

export default {
  data: () => {
    return {
      message: "<!-- testpage -->"
    };
  },
  methods: {
    uuid() { // called from a button @tap
      var uuid = plugin.getUUID();
      console.log("The device UUID is " + uuid);
    }
  }
};
</script>

3) 控制台输出:*CONSOLE LOG file:///app/components/Search.vue:32:0: '设备 UUID 为 B62CFD5E-C012-49E7-80CA-5DD9D0AC8F10'

4) 你也可以在mounted: 中做到这一点

【讨论】:

  • @Anton Franzen 你解决了问题吗?那么它不适用于“tns 预览”。
  • 我认为这一定是我的项目有问题,但我不知道为什么。我的代码和你用的一模一样
  • 我现在遇到了删除插件的问题。预览不再运行。 NativeScript 遇到致命错误:ReferenceError: Can't find variable: SSKeychain'
猜你喜欢
  • 2013-10-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-03-13
相关资源
最近更新 更多