小编Suh*_*pta的帖子

为什么我在chrome中遇到未定义函数的错误?

如果url是主页(即index.html),则某些css属性将应用于其某些元素.以下脚本运行正常,Mozilla Firefox但在Chrome说明函数contains未定义时出错.这是为什么 ?是不是,Chrome不将变量URL视为字符串?

var url = document.URL;
var links = document.getElementsByTagName("a");

if(url.contains("index.html")) {    
    document.links.item(0).style.color = "#FFFF00";
    document.links.item(0).style.borderBottom = "solid 2px white";

}
Run Code Online (Sandbox Code Playgroud)

javascript string firefox google-chrome

2
推荐指数
1
解决办法
176
查看次数

禁用日历中的所有日期

有没有办法禁用日历中的所有日期?当前的日历构造为:

$('.date-picker-field').datepicker( {
    showOtherMonths: true,
    selectOtherMonths: true,
    changeMonth: true,
    changeYear: true,
});
Run Code Online (Sandbox Code Playgroud)

这将显示一个启用了所有日期的日历。我想显示所有日期都被禁用。

jquery calendar jquery-ui jquery-ui-datepicker

2
推荐指数
1
解决办法
2793
查看次数

Exception类中的$ previous是什么?

是什么$previousException构造函数的参数分别表示?我该如何使用?

    class MyException extends \Exception {

    private $message;
    private $code;


    public function __construct($message,$code,\Exception $previous=null){
        $this->message = $message;
        $this->code = isset($code) ? $code : 0;
        parent::__construct($message,$code,$previous);      
    }       
}
Run Code Online (Sandbox Code Playgroud)

我没有在API文档中找到任何内容

php exception

2
推荐指数
1
解决办法
1696
查看次数

尝试构造可能长度为2的数组时出错

我试图构造一个长度为2的数组,但我得到一个打字稿错误:

[ts] Tuple type '[string]' with length '1' cannot be assigned
to tuple with length '2'.
Run Code Online (Sandbox Code Playgroud)
    let output = {status: false};
    if(execute.permission) {
        let message: [string] = execute.params;
        if(message.length >= 2) {
            // Destructuring follows
            [output['position'], output['message']] = message;
        }
    }
Run Code Online (Sandbox Code Playgroud)

我怎么告诉打字稿,这个数组的长度可能是2?

javascript destructuring typescript ecmascript-6

2
推荐指数
2
解决办法
1369
查看次数

通过转换和使用连接运算符将整数附加到字符串

我正在尝试将一个整数与现有字符串连接起来,casting并使用+. 但它不起作用。

package main

import (
    "fmt"
)

func main() {
    a := 4 
    b := "The value of a is "

    fmt.Println(b + string(a))
}
Run Code Online (Sandbox Code Playgroud)

这会在go 操场上打印一个垃圾字符,而在 Unix 终端上没有任何内容。这可能是什么原因?这种方法有什么问题?

string integer concatenation go

2
推荐指数
2
解决办法
7087
查看次数

将.class文件转换为jar文件时出错

我无法理解错误背后的原因.我想将.class文件转换为jar文件,

在我写道:

java cf myjar.jar*.class

但这是我得到的回报:

错误:无法在线程"main"java.lang.NoClassDefFoundError中找到主类cf Exception:cf
---并继续,,,,

为什么我得到这个错误,它是什么?

java jar

1
推荐指数
1
解决办法
260
查看次数

拒绝连接?

我的代码中出现以下异常: 在此输入图像描述

我无法理解这个例外的原因......

这是我的代码:{

import java.net.*;
 import java.io.*;
 class whois {
  public static void main(String args[])throws Exception {
   int c;
   Socket s=new Socket("internic.net",43);
   InputStream in=s.getInputStream();
   OutputStream out=s.getOutputStream();
   String str=(args.length==0 ? "webopedia.com" : args[0])+"\n";
   byte buf[]=str.getBytes();
   out.write(buf);
   while((c=in.read())!=-1) {
    System.out.print((char)c);
   }
    s.close();
   }
  }
 }
Run Code Online (Sandbox Code Playgroud)

请告诉这个例外的原因.

java

1
推荐指数
2
解决办法
874
查看次数

Y不递增

这是该计划:

#include<stdio.h>  

void main() {
    int *x,*y;
    int a=23,b=56;

    x=&a;
    y=&b;

    printf("%d\t%d",x,y);

    x++;
    y++;

    /* here only x is incremented but y remains same. What is the reason? */
    printf("\n%d\t%d",x,y);
}
Run Code Online (Sandbox Code Playgroud)

即x增加2.但是y保持不变.怎么样?

c

1
推荐指数
1
解决办法
157
查看次数

未插入新行

这是片段:

String s1=new String("127.0.0.1 www.google.com127.0.0.1 www.bing.com");
String s2=new String("127.0.0.1 www.google.com" + "\n" + "127.0.0.1 www.bing.com");
byte buffer1[]=s1.getBytes();
byte buffer2[]=s2.getBytes();
FileOutputStream fos=new FileOutputStream("f1.txt");
for(int i=0;i<buffer1.length;i++)
fos.write(buffer1[i]);
FileOutputStream fos2=new FileOutputStream("f2.txt");
for(int i=0;i<buffer2.length;i++)
fos2.write(buffer2[i]);
System.out.println("size of buffer1 = "+buffer1.length);
System.out.println("\nsize of buffer2 = "+buffer2.length);
String x=new String("s"+"\n"+"u");
System.out.println(x);
Run Code Online (Sandbox Code Playgroud)

我确实得到了2个文件f1.txtf2.txt在我当前的目录中,但我希望a 127.0.0.1 www.bing.com在新行中,f2.txt但它出现在同一行(即文件相同f1.txt).

f2.txt当我在String构造函数中插入新的行字符时,为什么不进入新行?

java file-io file

1
推荐指数
1
解决办法
1595
查看次数

编译错误,找不到符号和构造函数不能应用于给定的类型

我收到2个错误:

ControllingSpeed.java:89: constructor Thread in class Thread cannot be applied to given types
   Thread th=new Thread(r);
              ^
required: no arguments
found: Runnable
ControllingSpeed.java:90: cannot find symbol
   th.start(r);
     ^
symbol:   method start(Runnable)
location: class Thread
2 errors
Run Code Online (Sandbox Code Playgroud)

我不知道错误的原因.

// Demo On JSlider

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.lang.Thread.*;

class ControllingSpeed extends JPanel{

...<snip>...

public void threadForSpeed(final ChangeEvent ce) {   // <----- cause of error ?
    try { 
        Runnable r = new Runnable() {
            public void run() { …
Run Code Online (Sandbox Code Playgroud)

java compiler-errors

1
推荐指数
1
解决办法
4398
查看次数