3 回答

TA貢獻1829條經驗 獲得超6個贊
解決方案很簡單,幾個小時后,我刪除了所有的 html 格式并保留了標簽。
由此:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<link rel="stylesheet" href="https://unpkg.com/onsenui/css/onsenui.css">
<link rel="stylesheet" href="https://unpkg.com/onsenui/css/onsen-css-components.min.css">
<script src="https://unpkg.com/onsenui/js/onsenui.min.js"></script>
<link rel="stylesheet" href="style.css">
<title></title>
</head>
<body>
<ons-page id="home">
<ons-toolbar>
<div class="left"><ons-back-button>Page 1</ons-back-button></div>
</ons-toolbar>
<p>This is the second page.</p>
</ons-page>
</body>
</html>
對此:
<ons-page id="home">
<ons-card class="loginCard">
<ons-input id="userLogin" modifier="underbar" placeholder="Usuario" style="width: 100%; margin-top: 8px; margin-bottom: 8px;" float></ons-input>
<ons-input id="passLogin" modifier="underbar" placeholder="Contrase?a" type="password" style="width: 100%; margin-top: 8px; margin-bottom: 8px;" float></ons-input>
<ons-button class="loginButton" onclick="logintest()">ENTRAR</ons-button>
<ons-button class="loginFacebookButton">ENTRAR CON FACEBOOK</ons-button>
<label class="labelRegister">REGISTRARME</ilabel>
</ons-card>
</ons-page>

TA貢獻1859條經驗 獲得超6個贊
Onsen UI navigator 使用您指定頁面內容的模板,您無需創建不同的 html 文件來指定不同的頁面
document.addEventListener('init', function(event) {
var page = event.target;
if (page.id === 'page1') {
page.querySelector('#push-button').onclick = function() {
document.querySelector('#myNavigator').pushPage('page2.html', {data: {title: 'Page 2'}});
};
} else if (page.id === 'page2') {
page.querySelector('ons-toolbar .center').innerHTML = page.data.title;
}
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<link rel="stylesheet" href="https://unpkg.com/onsenui/css/onsenui.css">
<link rel="stylesheet" href="https://unpkg.com/onsenui/css/onsen-css-components.min.css">
<script src="https://unpkg.com/onsenui/js/onsenui.min.js"></script>
<link rel="stylesheet" href="style.css">
<title>App</title>
</head>
<body>
<ons-navigator swipeable id="myNavigator" page="page1.html"></ons-navigator>
<template id="page1.html">
<ons-page id="page1">
<ons-toolbar>
<div class="center">Page 1</div>
</ons-toolbar>
<p>This is the first page.</p>
<ons-button id="push-button">Push page</ons-button>
</ons-page>
</template>
<template id="page2.html">
<ons-page id="page2">
<ons-toolbar>
<div class="left"><ons-back-button>Page 1</ons-back-button></div>
<div class="center"></div>
</ons-toolbar>
<p>This is the second page.</p>
</ons-page>
</template>
</body>
</html>

TA貢獻1828條經驗 獲得超6個贊
從你的代碼看來,你</head>沒有開口<head>
但主要問題是你不能有 2 個標簽作為根,這意味著你需要用一個<html></html>標簽包裝它們
像這樣:
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
添加回答
舉報