【发布时间】:2018-11-07 10:28:03
【问题描述】:
我想在我的 react JS 应用程序中使用一些 Cordova 插件,但该应用程序一直失败。我知道 cordova 仅在运行时可用,我需要一种解决方法。
我的应用是通过 create react app with cordova here 创建的
比如我想导入cordova-plugin-device来获取设备uuid,代码如下:
import React, {Component} from 'react';
...
var device = require("cordova-plugin-device");
class Login extends Component {
handleSubmit = () => {
const { phone, password } = this.state
let params = {
phonenumber: phone,
password: password,
deviceID: device ? device.uuid : "test"
}
...
}
render () {
...
}
}
}
npm start 和运行 npm build 时出现错误。这是错误Module not found: Can't resolve 'cordova-plugin-device' in 'C:\projects\
任何关于如何实现这一点的指针将不胜感激。
【问题讨论】:
标签: reactjs cordova cordova-plugins