2016-01-05 91 views
1

我嘗試改變文本時,按鈕被點擊,但我的東西我錯過了一些東西 即時通訊使用onsen-ui新,並閱讀有關這個​​問題,所以我想出了我的JS不工作在移動>> 請如果任何人可以幫助!JS在Monaca(溫泉UI)中不起作用

<!doctype html> 
 
<meta charset="utf-8"> 
 
<link rel="stylesheet" href="lib/onsen/css/onsenui.css"> 
 
<link rel="stylesheet" href="lib/onsen/css/onsen-css-components.css"> 
 
<script src="lib/onsen/js/angular/angular.js"></script> 
 
<script src="lib/onsen/js/onsenui.js"></script> 
 
<script> 
 
    ons.bootstrap(); 
 
    
 
</script> 
 
<script> 
 
function myFunction() { 
 
    document.getElementById("demo").innerHTML = "Paragraph changed."; 
 
} 
 
</script> 
 
<body> 
 
<h1>JavaScript in Head</h1> 
 

 
<p id="demo">A Paragraph.</p> 
 

 
<button type="button" onclick="myFunction()">Try it</button> 
 
    </ons-page> 
 
    </ons-navigator> 
 
</body>

回答

2

你忘了添加<ons-navigator><ons-page>標籤。如果您注意到,它們已關閉,但從未打開過。

這裏如果固定碼:

<!doctype html> 
<meta charset="utf-8"> 
<link rel="stylesheet" href="lib/onsen/css/onsenui.css"> 
<link rel="stylesheet" href="lib/onsen/css/onsen-css-components.css"> 
<script src="lib/onsen/js/angular/angular.js"></script> 
<script src="lib/onsen/js/onsenui.js"></script> 
<script> 
    ons.bootstrap(); 
</script> 
<script> 
    function myFunction() { 
    document.getElementById("demo").innerHTML = "Paragraph changed."; 
    } 
</script> 

<body> 
    <ons-navigator> 
    <ons-page> 
     <h1>JavaScript in Head</h1> 

     <p id="demo">A Paragraph.</p> 

     <button type="button" onclick="myFunction()">Try it</button> 
    </ons-page> 
    </ons-navigator> 
</body>