还有一对父母div用id = "cooldiv".div里面有很多元素.现在我需要为所有子div节点设置一个css属性,除了第一个.
所以,这是我到目前为止完成这项任务所尝试的:
#cooldiv .row:not(first-child) {
top: -50px;
}
Run Code Online (Sandbox Code Playgroud)
但是,当然,它没有成功.这有什么不对?这是源代码的截图:
我在一个名为'Upload'的控制器中有一个带有参数HttpPostedFileBase对象的方法,我从视图中发布了该文件并成功保存到文件夹中.但是当我尝试返回具有以下内容的JSON字符串对象时,它会抛出一条带有消息的异常:
"从'System.Web.HttpInputStream'''ReadTimeout'获取值时出错."
如果是'files = files',如果我将其删除,则会正确返回.但我需要这些数据
public string Upload(HttpPostedFileBase files)
{
try
{
if (files != null && files.ContentLength > 0)
{
var path = Path.Combine(Server.MapPath("~/Uploads"), files.FileName);
files.SaveAs(path);
return JsonConvert.SerializeObject(
new
{
files=files,
Passed = true,
Mesaj = "item added"
});
}
}
}
Run Code Online (Sandbox Code Playgroud) 我是laravel的新手,我运行查询并从数据库中获取行,我想在将它们放入视图之前编辑这些行的列.所以这是我的代码片段:
$callPlans = CustomerCallPlan::whereNotNull('id');
foreach ($callPlans->get() as $callPlan) {
dd($callPlan);
}
Run Code Online (Sandbox Code Playgroud)
并输出截图:
我需要用' - ' numbertemplate列替换所有'x'字符.
检索数据并设置obseravble数组,这里的代码如下:
import {observable} from 'mobx';
export interface IMenuModel{
Id:number
itemName:string;
parentId?:number;
}
class MenuRepo {
@observable menuItems? : IMenuModel[];
constructor(){
}
getItems():void {
fetch(`..`).then((response: Response): Promise<{ value:IMenuModel[] }> => {
return response.json();
})
.then((response: { value: IMenuModel[] }) : void => {
this.menuItems = response.value;
}, (error: any): void => {
//exception handling
});
}
}
var menuCodes = new MenuRepo
export default menuCodes;
Run Code Online (Sandbox Code Playgroud)
这是观察者阶级;
import * as React from 'react';
import {observer} from 'mobx-react';
import {IMenuModel} from './Codes';
@observer …Run Code Online (Sandbox Code Playgroud) 有包含数据的对象列表,如下所示:
[
{name: 'Foo 1'},
{name: 'Foo 14'},
..
{name: 'Foo 2'},
{name: 'Bar 1'},
{name: 'Bar 15'},
...
{name: 'Bar 2'},
]
Run Code Online (Sandbox Code Playgroud)
我需要将其排序为
[
{name: 'Bar 1'},
{name: 'Bar 2'},
...
{name: 'Bar 15'},
{name: 'Foo 1'},
{name: 'Foo 1'},
...
{name: 'Foo 12'},
]
Run Code Online (Sandbox Code Playgroud)
通过经典的字符排序,“Foo 14”领先于“Foo 2”,因此我需要按字母和数字进行排序。
值模式:可能有多个单词,但总是以数字结尾,例如“word word .. number”
我的登录页面和应用程序中的其他页面具有不同的类,因此在用户登录后,我需要更改body元素的类。在这里,我试图做到这一点。
index.html
<body [ngClass]="{
'dashboard site-navbar-small' :isAuthenticated,
'login-form login-form-second page-login-second' :!isAuthenticated
}">
<app-root>Loading...</app-root>
Run Code Online (Sandbox Code Playgroud)
login.component.ts
export class LoginComponent {
@HostBinding('class.login-form.login-form-second.page-login-second')
siteNavbarSmallClass = false;
constructor(private auth:Auth){
this.siteNavbarSmallClass=this.auth.authenticated();
}
}
Run Code Online (Sandbox Code Playgroud)
app.component.ts
export class AppComponent {
@HostBinding('class.dashboard.site-navbar-small')
dashboardClass = false;
constructor(private auth:Auth){
this.dashboardClass=this.auth.authenticated();
}
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试将ngClass指令绑定到isAuthenticated字段..但我不受影响。我听说我们无法通过ts更改body元素,但是我该如何处理呢?
我已经创建了自定义验证器(cannotContainSpace)并想要使用它模板组件(postmessage.component),但不知何故验证器无法看到我创建的自定义验证器类..这里是编译器消息:

usernamevalidator.ts
import {FormControl} from '@angular/forms';
export class UsernameValidator{
static cannotContainSpace(control:FormControl){
if(control.value.indexOf('')>=0)
return { cannotContainSpace:true };
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
postmessage.component.ts
import { Component } from '@angular/core';
import {FormControl,FormGroup,FormBuilder,Validators} from '@angular/forms';
import {UsernameValidator} from '../../validators/usernamevalidator';
@Component({
moduleId:module.id,
selector: 'post-message',
templateUrl: '../../templates/postmessage.component.html'
})
export class PostComponent {
form : FormGroup;
constructor(fb:FormBuilder){
this.form = fb.group({
username:['', Validators.compose([Validators.required, Validators.cannotContainSpace])],
email:['', Validators.required],
message:['', Validators.required]
});
}
signup(){
console.log(this.form.value);
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个方法,它根据请求 url 返回一个对象或一组相同对象。逻辑很简单;
myservice.service.ts:
private _url_User = "https://api.github.com/users/dummyuser";
constructor(private _http: Http){}
getUsers(followers?: boolean): Observable<User | User[]>{
this._url_User += followers?"/followers":"";//if followers equals true edit url, this returns array of same user object
return this._http.get(this._url_User).map(res=>res.json());
}
Run Code Online (Sandbox Code Playgroud)
mycomponent.component.ts:
import { Component,OnInit } from '@angular/core';
import {Auth} from '../../services/auth.service';
import {CommentService} from '../../services/comment.service';
import {User} from '../../infrastructure/user';
@Component({
moduleId:module.id,
selector: 'app-comment',
templateUrl: '../../templates/comment.component.html'
})
export class CommentComponent implements OnInit{
user:User;
followers:User[];
constructor(private auth: Auth, private commentService: CommentService){
}
ngOnInit(){
this.commentService.getUsers().subscribe(d=>{ this.user=d[0]; console.log(this.user.email)});
this.commentService.getUsers(true).subscribe(d=>{this.followers=d; console.log(this.followers[0].email)}); …Run Code Online (Sandbox Code Playgroud) 我用create-react-app命令创建了启动项目.并添加了两个生命周期事件,componentDidMount()工作正常但componentWillReceiveProps()不会触发.
index.js:
ReactDOM.render(
<App appState={appState} />,
document.getElementById('root')
);
Run Code Online (Sandbox Code Playgroud)
App.js:
class App extends Component {
render() {
return (
<div className="App">
<EasyABC appState={this.props.appState} />
</div>
)
}
}
export default App;
Run Code Online (Sandbox Code Playgroud)
EasyABC.jsx文件:
@observer
export default class EasyABC extends Component{
constructor(props){
super(props)
}
componentDidMount(){
this.props.appState.index=0
let letterSound = document.querySelector("audio[data-key='letter']")
letterSound.play()
}
componentWillReceiveProps(){//never stops here
debugger
}...
Run Code Online (Sandbox Code Playgroud)
如果需要的话; 的package.json:
{
"name": "assasment1",
"version": "0.1.0",
"private": true,
"dependencies": {
"classnames": "^2.2.5",
"mobx": "^3.2.0",
"mobx-react": "^4.2.2",
"react": "^15.6.1",
"react-dom": "^15.6.1"
},
"devDependencies": {
"custom-react-scripts": "0.0.23" …Run Code Online (Sandbox Code Playgroud) 我进行搜索并将其与适当的解决方案进行比较,看起来没有什么错,但是我几乎得到了如下所示的错误屏幕;
这里的导航代码有什么问题;
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
TouchableOpacity
} from 'react-native';
import { StackNavigator } from 'react-navigation';
import About from './app/components/About';
export default class Home extends Component {
static navigationOptions = {
title: 'Welcome',
};
navigateToAbout(){
const { navigate } = this.props.navigation;
navigate('About')
}
render() {
return (
<View style={styles.container}>
<TouchableOpacity onPress={()=>this.navigateToAbout()}>
<Text>Go to About Page</Text>
</TouchableOpacity>
</View>
);
}
}
const SimpleApp = StackNavigator({
Home: { screen: Home },
About: { …Run Code Online (Sandbox Code Playgroud) reactjs ×3
typescript ×3
angular ×2
css ×1
css3 ×1
eloquent ×1
html ×1
javascript ×1
json ×1
laravel ×1
laravel-5 ×1
mobx ×1
mobx-react ×1
php ×1
react-native ×1