小编pra*_*kar的帖子

如何在输入中只使用占位符斜体

嗨,任何人都可以告诉我,我怎么能只做占位符斜体,但当有人在测试盒内写字时,书面文字不应该有斜体.

mycode的:

<input type="text" id="search" placeholder="Search" style="font-style:italic">
Run Code Online (Sandbox Code Playgroud)

我怎么能把斜体放在占位符上而不是整个输入?

html input placeholder

42
推荐指数
2
解决办法
4万
查看次数

为什么我们不需要在React中绑定箭头功能?

我们都知道我们需要在React中绑定函数以使其起作用。我知道为什么我们需要绑定它。

但是我不确定为什么我们不需要绑定箭头功能。

示例:使用箭头功能(无需绑定)

handleClick = () => {
  this.setState({
    isToggleOn: !this.state.isToggleOn
  });
Run Code Online (Sandbox Code Playgroud)

};

现在,使用功能(需要绑定)

this.handleClick = this.handleClick.bind(this);

handleClick() {
  this.setState({
    isToggleOn: !this.state.isToggleOn
  });
Run Code Online (Sandbox Code Playgroud)

};

我不是在问为什么我们需要绑定功能。我只想知道为什么箭头功能不需要绑定。

谢谢。

reactjs arrow-functions

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

Making site multi language support using google translate for React js

For simple html projects i can simple refer this link.

https://www.w3schools.com/howto/howto_google_translate.asp

But I'm trying to implement in react app . So I'm not able to replicate the code in react app.

componentDidMount() {
  googleTranslateElementInit(() => {
    new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element');
    });
    const script = document.createElement("script");
    script.src = "//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit";
    script.async = true;
    document.body.appendChild(script);
}
Run Code Online (Sandbox Code Playgroud)

And return render element .

  render() {
    return (
      <div id="google_translate_element"></div>
    );
  }
Run Code Online (Sandbox Code Playgroud)

This is showing me error saying google , googleTranslateElementInit is not defined.

How can …

javascript google-translate reactjs

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

在linq中展平列表

我们假设我的列表是这样的:

List<List<string>> zz = new List<List<string>>() { new List<string>{"1","2","3"}, new List<string> { "4", "5", "6" } };
Run Code Online (Sandbox Code Playgroud)

我想要一个列表作为输出如下:

List<string> finalList = new List<string>{"1","2","3","4", "5", "6"};
Run Code Online (Sandbox Code Playgroud)

我该如何做到这一点?

.net c# linq

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