我有一个像下面这样的div的页面
<div id="container">
<div id="A">
</div>
<div id="B">
<div id="B1"></div>
<div id="B2">B2</div>
</div>
<div id="C"></div>
<div id="D">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
造型为;
html, body {
margin: 0;
padding: 0;
border: 0;
}
#B, #C, #D {
position: absolute;
}
#A{
top: 0;
width: 100%;
height: 35px;
background-color: #99CC00;
}
#B {
top: 35px;
width: 200px;
bottom: 35px;
background-color: #999999;
z-index:100;
}
#B2 {
margin-top: -35px;
bottom: 0;
background-color: #FFFFFF;
width: 200px;
overflow: scroll;
}
#B1 {
height: 35px;
width: 35px;
margin-left: 200px; …Run Code Online (Sandbox Code Playgroud) 为什么你不能[AnyObject]?直接循环?什么意思没有命名的发电机?循环一种[AnyObject]?类型的正确技术是什么?
这段代码给我一个错误,告诉我它没有名为generator的成员.
for screen in NSScreen.screens() {
var result : Bool = workspace.setDesktopImageURL(imgurl, forScreen: screen, options: nil, error: &error)
}
Run Code Online (Sandbox Code Playgroud) 我想将Double加倍到一定数量的小数,总是四舍五入.
例
舍入到.00 => 1.5679999到1.56
舍入到.000 => 1.5679999到1.567
round(1.5679999 * 100) / 100 //returns 1.57
round(1.5679999 * 1000) / 1000 //returns 1.568
Run Code Online (Sandbox Code Playgroud)
我想要一个Double而不是一个连接的字符串
在iOS上的Restkit中有一个详细的调试选项.RKLogConfigureByName("*", RKLogLevelTrace);.有谁知道Volley是否有相同的东西.基本上我直接使用ErrorListener,但我没有在LogCat中获得其他信息.都:
VolleyLog.e("Error: ", error.toString());
Run Code Online (Sandbox Code Playgroud)
和:
VolleyLog.e("Error: ", error.getMessage());
Run Code Online (Sandbox Code Playgroud)
打印:
2.onErrorResponse: Error:
Run Code Online (Sandbox Code Playgroud) 如何访问处于相同状态的其他子视图.我正在构建一个顶部有一个工具栏的页面和一个侧边栏,我想要一个工具栏上的按钮来打开/关闭边栏中的侧边栏和按钮来更改内容.很简单它都在同一个控制器中,但我所做的是使用ui-router的子视图功能,如下所示:
.state('dash', {
url: '/dash/:id',
views: {
nav: {
controller: 'NavCtrl',
controllerAs: 'ctrl',
templateUrl: '/views/navbar.html'
},
sidebar: {
controller: 'SidebarCtrl',
controllerAs: 'ctrl',
templateUrl: '/views/sidebar.html'
},
content: {
controller: 'DashCtrl',
controllerAs: 'ctrl',
templateUrl: '/views/dash.html'
}
}
})
Run Code Online (Sandbox Code Playgroud)
UI看起来像这样:
我的州等级是(从上到下):
rootaccountaccount.invoicesaccount.invoices.detail当我在 account.invoices.detail州时,我想得到一个祖先状态列表:
angular
.module('app')
.controller('InvoiceDetailCtrl', ['$scope', '$state', function ($scope, $state) {
var current = $state.current.name;
// Get ancestors from current state
// Tried $state.current.parent, $state.parent, $state.parent(current)
}]);
Run Code Online (Sandbox Code Playgroud)
Angular UI路由器允许您转换到父状态(即从视图中data-ui-sref="^"),因此应该可以实现这一点(跟随祖先的链root).
我需要这个来构建类似auto-breadcrumbs的功能.
编辑:由于接受的答案,最终得到了这个:
var current = $scope.$state.$current,
parent = current.parent,
ancestors = [current.name];
while (typeof parent != 'undefined' && parent.name.length) {
ancestors.push(parent.name);
parent = parent.parent;
}
Run Code Online (Sandbox Code Playgroud)
如果你问为什么检查parent.name.length它,因为在Angular UI中有类似"root"状态(无法获得任何文档).
我试图了解当用户按下后我发生了什么,我没有覆盖onOptionsItemSelected.
我有以下场景:
intent.putExtra("abc", "abc"); getIntent()inonCreate()当用户点击活动C时会发生什么?
如果我不覆盖后退按钮,则按下后退将在getIntent行上产生nullException.为什么?它onCreate()不在onStart().
如果我使用onSaveInstanceStatebundle总是空的.这导致我假设back正在创建Activity的新实例.为什么?它应该完成自己.
如果我用finish()它覆盖后退按钮不再崩溃,但我认为后面的默认行为是运行finish().
编辑更多细节:
我在每个生命周期方法中都举杯祝酒,我发现在我按下活动C 后,活动B会调用destroy .这对我没有意义!
表现:
活动A.
<activity
android:name=".activities.MainActivity"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
活动B.
<activity
android:name=".activities.MenuActivity"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:label="@string/menu_title"
android:parentActivityName=".activities.MainActivity">
</activity>
Run Code Online (Sandbox Code Playgroud)
活动C.
<activity
android:name=".activities.OptionActivity"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:label="@string/option_title"
android:parentActivityName=".activities.MenuActivity">
</activity>
Run Code Online (Sandbox Code Playgroud) 我有一个使用wget3g设备上运行的bash脚本.我希望脚本暂停,直到我得到响应,所以我设置了我的代码:
wget -t 0 -T 15 --retry-connrefused www.example.com
Run Code Online (Sandbox Code Playgroud)
问题是,当根本没有连接时(3g下降几秒钟),DNS无法解析主机并wget停止重试.
有没有办法强制重试,直到连接回来?我知道我可以写一个循环,但我想知道我是否有wget可以使用的设置.如果没有什么最好的变量来构建循环?
更多细节:
使用我编写的代码,wget将重试,但如果设备根本没有Internet连接(例如我从设备中拔出3g加密狗),它将停止重试,告诉我它无法解析主机地址.它在定义的15秒后发送-T 15
wget: unable to resolve host address
Run Code Online (Sandbox Code Playgroud) 在使用组件时,如何使用UI路由器解析变量.
这是路线:
$stateProvider
.state('route', {
url: '/route',
template: '<my-component user="user"></my-component>',
resolve: {
user: (Auth) => {
return Auth.getCurrentUser().$promise;
}
}
})
Run Code Online (Sandbox Code Playgroud)
这是组件:
(function () {
class BookingListComponent {
constructor(user) {
//I want to use the user here but getting the unknown provider error
}
}
angular.module('app')
.component('myComponent', {
templateUrl: 'my-url.html',
controller: MyComponent,
bindings: {
user: '<'
}
});
})();
Run Code Online (Sandbox Code Playgroud)
使用Angular 1.5和yeoman angular-fullstack
我正在使用OpenWrt和非常小的空间。
尝试从文件中提取第一行。该行需要进入变量,然后从文件中删除。我可以head将其放入变量中,但不能使用,tail因为据我所知我必须这样做,tail file > newFile并且我没有第二个文件的空间。
有人知道是否有更好的技术吗?