我在我的主index.html文件中加载了一个库(cordova)。然后我在我的文档中添加了eventlistener'deviceready'。现在我如何在react组件中调用此函数和相关库?
Html文件:
<!DOCTYPE html>
<html>
<head>
<title>title</title>
</head>
<body>
<div id="app"></div>
</body>
<script type="text/javascript" src="cordova.js"></script>
<script>
document.addEventListener('deviceready', onDeviceReady);
// this is the function I want to call inside my component.
// function onDeviceReady() {
// var rect = { x: 0, y: 0, width: window.innerWidth, height: window.innerHeight };
// cordova.plugins.camerapreview.startCamera(rect, 'back', true, true, true)
// cordova.plugins.camerapreview.show();
// }
</script>
</html>
我的反应成分:
import React, { Component } from 'react';
class Example extends Component {
// Here I want to call my cordova actions inside the eventlistener
render() {
return (
<div>
<p>Example</p>
</div>
);
}
}
export default Example;
答案 0 :(得分:2)
使用A: Passing Parameters to a Stored Procedure using ASP是添加和删除事件的正确方法
所以你可以这样做:
cmds.arclen('bezier1')