如何解决系统信息只是待定,在 vue 中不显示任何结果
作为我的个人项目,我想使用 Electron 和 Vue 制作一个桌面应用程序。我已经完成了所有设置并使用已经完成的 gui 完美运行,但是有一个小问题。要获取系统信息,我使用 systeminformation 并在 General.vue 文件的脚本标记中调用它不起作用。
General.js
<script>
import { defineComponent } from 'vue'
import systeminformation from 'systeminformation'
export default defineComponent({
name: 'General',mounted () {
this.getData() // Call the function once started
},methods: {
getData: function () {
console.log('test 1') // Gets printed out
systeminformation.cpu()
.then(data => console.log(data)) // All of these do nothing
.catch(reason => console.log(reason))
.finally(() => console.log('test 1.5'))
console.log('test 2') // Gets printed out
}
}
})
</script>
此代码应该获取有关我设备的 cpu 的所有信息,但除了测试之外,控制台中没有显示任何内容。我已经尝试在一个只使用基本 Node 的简单测试项目中运行它,并且它按预期运行。
关于为什么它在这里不起作用,我唯一的理论可能是它在 .vue 中并且离应用程序的后端部分太远了?我将非常感谢任何帮助。如果您想进行实验,这里有一个 link 项目供您克隆它。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。