我需要检查是否myDiv1已禁用.如果是这样,我需要隐藏myDiv2,否则我需要展示myDiv2.
这是我到目前为止:
$(document).ready(function () {
var isDisabled = $('#myDiv1').is('[disabled=disabled]')
alert(isDisabled); //this always returns false
if(isDisabled)
$("#myDiv2").hide();
else
$("#myDiv2").show()
});
Run Code Online (Sandbox Code Playgroud)
但即使启用也会isDisabled返回.我在这里错过了什么?falsemyDiv1
我已经webbrowser.open(url)在 python 中打开了一个 webbrowser 窗口,现在我想关闭使用 python 打开的 webbrowser。有可能这样做吗?
我试图从HTTP请求中捕获错误,并基于错误代码向用户显示错误消息。为此,我使用rxjs中的catchError运算符。
但是我收到这个错误,指出类型Observable <Response>上不存在属性'catchError'
以下是我的package.json
"dependencies": {
"@angular/animations": "^6.0.3",
"@angular/common": "^6.0.3",
"@angular/compiler": "^6.0.3",
"@angular/core": "^6.0.3",
"@angular/forms": "^6.0.3",
"@angular/http": "^6.0.3",
"@angular/platform-browser": "^6.0.3",
"@angular/platform-browser-dynamic": "^6.0.3",
"@angular/router": "^6.0.3",
"bootstrap": "^3.3.7",
"core-js": "^2.5.4",
"rxjs": "^6.0.0",
"zone.js": "^0.8.26"
Run Code Online (Sandbox Code Playgroud)
以下是我正在实现的用于处理http请求的服务中使用的导入。
import { catchError } from 'rxjs/operators';
import { Injectable } from '@angular/core';
import { Http } from '../../../node_modules/@angular/http';
import { Observable } from 'rxjs';
import { AppError } from './../common/app-error';
import { NotFoundError } from '../common/not-found-error';
Run Code Online (Sandbox Code Playgroud)
这是我从服务器上删除帖子并为预期和意外错误返回自定义错误的功能。
deletePost(id:number){
return this.http.delete(this._url+"/"+id).catchError(
(error:Response)=>{
if(error.status===404){
return Observable.throw(new NotFoundError());
} …Run Code Online (Sandbox Code Playgroud)