1

ボタンがクリックされたときにテキストを変更しようとしましたが、onsen-ui を使用する際に何か新しいことを見逃していて、この問題について読んだので、私の JS がモバイルで機能しないことがわかりました >> 誰か助けてください!!

<!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>

4

1 に答える 1

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>
于 2016-01-05T05:37:02.073 に答える