2015-01-15 4 views
0

Cordova 플러그인을 설치했습니다. 플러그인을 사용할 때까지 모든 것이 성공적으로 완료되었습니다. Android 용 플러그인 만 있으면됩니다.cordova 플러그인이 작동하지 않습니다.

http://plugins.cordova.io/#/package/net.yoik.cordova.plugins.screenorientation

내가 플러그인 내 디렉토리 (-> net.yoik.cordova.plugins.screenorientation 플러그인)에 설치를 참조하십시오 이것은 내가 사용하는 노력하고있어 플러그인입니다.

내 자바 스크립트 코드 :

window.onload = function() { 

// access current orientation 
console.log('Orientation is ' + screen.orientation); 

screen.lockOrientation('portrait'); 

// access current orientation 
console.log('Orientation is ' + screen.orientation); 
}; 

을 console.log 쇼 '가 정의되지 않은'.

내 config.xml 파일 :

<?xml version='1.0' encoding='utf-8'?> 
<widget id="com.example.hello" 
    version="0.0.1" 
    xmlns="http://www.w3.org/ns/widgets" 
    xmlns:gap = "http://phonegap.com/ns/1.0" 
    xmlns:cdv="http://cordova.apache.org/ns/1.0"> 


<name>Shoot Out</name> 

<author email="[email protected]" href="http://cordova.io"> 
    Apache Cordova Team 
</author> 

<preference name="permissions"    value="none"/> 

<!-- Customize your app and platform with the preference element. --> 
<preference name="orientation"    value="default" /> 
<preference name="target-device"    value="universal" /> 
<preference name="fullscreen"     value="false" /> 
<preference name="webviewbounce"    value="false" /> 
<preference name="prerendered-icon"   value="true" /> 
<preference name="stay-in-webview"   value="true" /> 
<preference name="ios-statusbarstyle"   value="black-opaque" /> 
<preference name="detect-data-types"   value="true" /> 
<preference name="exit-on-suspend"   value="false" /> 
<preference name="show-splash-screen-spinner" value="true" /> 
<preference name="auto-hide-splash-screen" value="true" />  
<preference name="disable-cursor"    value="false" /> 
<preference name="android-minSdkVersion"  value="7" />  
<preference name="android-installLocation" value="auto" /> 

<!-- Plugins --> 
<gap:plugin name="net.yoik.cordova.plugins.screenorientation" version="1.3.1" /> 
<access origin="*" /> 

내 인덱스 파일 : 나는 함께, 내 PC와 내 휴대폰 (안드로이드)에 모두를 시도했습니다

<!DOCTYPE html> 
<html> 
<head> 
<meta charset="utf-8"/> 
<meta name="format-detection" content="telephone=no"/> 
<meta name="msapplication-tap-highlight" content="no"/> 
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 --> 
<!--<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=4, maximum-scale=1, minimum-scale=1, height=device-height, target-densitydpi=device-dpi" />--> 
<meta name="viewport" 
     content="width=device-width, initial-scale=1.0, maximum-scale=1.0, target-densitydpi=low-dpi, user-scalable=0"/> 
<link rel="stylesheet" type="text/css" href="css/style.css"/> 
<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"> 
<script src="http://code.jquery.com/jquery-latest.min.js"></script> 

<!-- FIREBASE CONNECTION --> 
<script src="https://cdn.firebase.com/js/client/2.0.4/firebase.js"></script> 

<script src="js/getCurrentGames.js"></script> 
<script src="js/main.js"></script> 
<title>Groot Project</title> 
</head> 
<body> 
<div id="all"></div> 
</body> 
</html> 

같은 오류. 어떤 생각?

<script type="text/javascript" src="cordova.js"></script> 

에 : 장치가 나는이를 추가하여 고정

document.addEventListener("deviceready", function() { 

    // access current orientation 
    console.log('Orientation is ' + screen.orientation); 

    screen.lockOrientation('portrait'); 

    // access current orientation 
    console.log('Orientation is ' + screen.orientation); 
}, false); 

답변

1

준비가 될 때까지

0

대신 온로드를 사용하는의 코르도바/폰갭 deviceready 이벤트를 사용하여, 당신은 플러그인을 사용할 수 없습니다 내 index.html

관련 문제