phonegap + jquery mobile:css无法正常工作

Jan*_*o67 4 html css jquery android cordova

我有一个phonegap项目,我愿意使用jquery mobile.我已经找了一些例子,从已经测试的东西开始,这是我的问题.当我在Nexus 5上启动应用程序时,所有元素都显示没有任何风格.也许这只是放置代码所以这是我的.希望有人能找到问题:

的index.html

<!DOCTYPE HTML>
<html>
<head>
<title>Employee Directory</title>
<meta name="viewport" content="width=device-width,initial-scale=1"/>
<link rel="stylesheet" href="css/jquery.mobile-1.4.5.min.css" />
<link rel="stylesheet" href="css/styles.css" />
</head>

<body>

<div data-role="page" class="jqm-demos ui-responsive-panel" id="panel-responsive-page1" data-title="Panel responsive page" data-url="panel-responsive-page1">
<div data-role="header">
<h1>Panel responsive</h1>
    <a href="#nav-panel" data-icon="bars" data-iconpos="notext">Menu</a>
    <a href="#add-form" data-icon="gear" data-iconpos="notext">Add</a>
</div><!-- /header -->
<div role="main" class="ui-content jqm-content jqm-fullwidth">
    <h1>Panel responsive</h1>
    <p>This is a typical page that has two buttons in the header bar that open panels. The left panel has the push display mode, the right panel reveal. To make this responsive, you can make the page re-flow at wider widths. This allows both the panel menu and page to be used together when more space is available. This behavior is controlled by CSS media queries. You can create a custom one for a specific breakpoint or use the breakpoint preset by adding the <code>class="ui-responsive-panel"</code> to the page container. We have added this class on this demo page. Note that when using the preset class, we also hide the dismiss layer on wider screens if the panel has the push display mode.</p>
<div data-demo-html="#panel-responsive-page1"></div><!--/demo-html -->
<br><br><br><br><br>
<a href="../" data-rel="back" data-ajax="false" class="ui-btn ui-shadow ui-corner-all ui-mini ui-btn-inline ui-icon-carat-l ui-btn-icon-left ui-alt-icon ui-nodisc-icon">Back</a>
</div><!-- /content -->
<div data-role="panel" data-display="push" data-theme="b" id="nav-panel">
    <ul data-role="listview">
        <li data-icon="delete"><a href="#" data-rel="close">Close menu</a></li>
        <li><a href="#panel-responsive-page2">Accordion</a></li>
     [...]
        <li><a href="#panel-responsive-page2">Transitions</a></li>
    </ul>
</div><!-- /panel -->
<div data-role="panel" data-position="right" data-display="reveal" data-theme="a" id="add-form">
    <form class="userform">
        <h2>Login</h2>
        <label for="name">Username:</label>
        <input type="text" name="name" id="name" value="" data-clear-btn="true" data-mini="true">
        <label for="password">Password:</label>
        <input type="password" name="password" id="password" value="" data-clear-btn="true" autocomplete="off" data-mini="true">
        <div class="ui-grid-a">
            <div class="ui-block-a"><a href="#" data-rel="close" class="ui-btn ui-shadow ui-corner-all ui-btn-b ui-mini">Cancel</a></div>
            <div class="ui-block-b"><a href="#" data-rel="close" class="ui-btn ui-shadow ui-corner-all ui-btn-a ui-mini">Save</a></div>
        </div>
      </form>
 </div><!-- /panel -->
</div>

<script src="js/jquery.js"></script>
<script src="js/jquery.mobile-1.4.5.min.js"></script>
<script src="js/employeelist.js"></script>
<script src="js/employeedetails.js"></script> 
<script src="js/reportlist.js"></script>

</body>

</html>
Run Code Online (Sandbox Code Playgroud)

MainActivity.java

package com.uplink.agriturismo.com;

import org.apache.cordova.*;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class MainActivity extends DroidGap {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.setIntegerProperty("splashscreen", R.drawable.screen);
    super.loadUrl("file:///android_asset/www/index.html");
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}
}
Run Code Online (Sandbox Code Playgroud)

raj*_*raj 10

我坚持同样的问题终于发现该页面无法获取css目录.

使用

<link rel="stylesheet" href="./css/jquery.mobile-1.4.5.min.css" />
<link rel="stylesheet" href="./css/styles.css" />
Run Code Online (Sandbox Code Playgroud)

  • 像喂宝宝一样容易..谢谢! (2认同)
  • ./(点斜线)是修复,非常感谢:) (2认同)