V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  morri  ›  全部回复第 6 页 / 共 6 页
回复总数  115
1  2  3  4  5  6  
2022-09-02 14:30:32 +08:00
回复了 morri 创建的主题 程序员 telegram web 端 没有使用 websocket 是如何接收消息呢?
@SWBMESSI Service Worker 嗯,了解一下
@darkengine 多谢回答,这样也不行 还是要在遍历的里面使用 const [show, setShow] = React.useState(false) 才行
@GentleFifth 写过

@GPLer 多谢回答!
我试过 有调用 ` setItems(items[index].show = true)` 这样也不行。
@darkengine
<div className="wrapper">
{items.map((i, index) => {
i.show = false
return <div key={i.name} className="box" onClick={() => {
setItems(items[index].show = true)
}}>
<p>名称 {i.name}</p>
<p>年龄: {i.age}</p>
<a href="#">设置</a>
<div className={i.show ? 'menu-show' : 'menu-hide'}>
<p>名称: {i.name}</p>
<p>年龄: <input type="text"/></p>
</div>
</div>
})}
</div>



但是 在 telegram 群里面问的哥哥 这样改下就可以了 在遍历里面 再使用 ` const [show, setShow] = React.useState(false);`

```

<div className="wrapper">
{items.map(i => {
const [show, setShow] = React.useState(false);
return <div key={i.name} className="box" onClick={() => setShow(v => !v)}>
<p>名称 {i.name}</p>
<p>年龄: {i.age}</p>
<a href="#">设置</a>
<div className={show ? 'menu-show' : 'menu-hide'}>
<p>名称: {i.name}</p>
<p>年龄: <input type="text"/></p>
</div>
</div>
})}
</div>

```
好奇为什么要这样用才行。
2022-08-17 12:44:15 +08:00
回复了 wely 创建的主题 程序员 程序员的出路究竟在哪?
线下开店,线上创建自己的产品,不管竞争有多激烈,都要做下去,并且做得尽可能好~

种树,养鸡,织网。
2022-08-12 19:22:25 +08:00
回复了 qzhai 创建的主题 奇思妙想 SEO 是玄学么?
在别的网站挂外链效果怎样呢?
2022-08-03 10:50:27 +08:00
回复了 baozhilv 创建的主题 职人 有目标,但是没动力,是不是已成咸鱼了
先努力做一个能自动创收的东西,再来混混噩噩也不迟,对不对
@wxf666 @lmshl @FYFX @sutra
大佬们都厉害,向你们学习~
@wxf666 多谢,可以~
@wxf666
最特别的值就是 `options:"1:yes:tag-info,2:no:tag-danger"`
因为这个 key 如果有出现那么它的值格式是这样的`value1:label1:class1,value2,label2,class2...` 如果是在不好判断,就让 `options` 的值必须带 “” 双引号吧。让程序单独判断一下..
@wxf666 键是固定的几个,但是位置可以随意变化的,因为都是可选。
@wxf666 厉害上天~
@sutra
@wxf666 谢谢 我后面改改

现在这样写的

```
func makeToJsonStr(str string) string {
// 替换所有空格
replace, _ := gregex.Replace(`\s`, []byte(""), []byte(str))
// 处理 key 未加""的内容字段
replace, _ = gregex.Replace(`label|"label"`, []byte(`"label"`), replace)
replace, _ = gregex.Replace(`fieldType|"fieldType"`, []byte(`"fieldType"`), replace)
replace, _ = gregex.Replace(`searchType|"searchType"`, []byte(`"searchType"`), replace)
replace, _ = gregex.Replace(`editHide|"editHide"`, []byte(`"editHide"`), replace)
replace, _ = gregex.Replace(`addHide|"addHide"`, []byte(`"addHide"`), replace)
replace, _ = gregex.Replace(`hide|"hide"`, []byte(`"hide"`), replace)
replace, _ = gregex.Replace(`disabled|"disabled"`, []byte(`"disabled"`), replace)
replace, _ = gregex.Replace(`required|"required"`, []byte(`"required"`), replace)
replace, _ = gregex.Replace(`comment|"comment"`, []byte(`"comment"`), replace)
replace, _ = gregex.Replace(`options|"options"`, []byte(`"options"`), replace)
// 处理值未加个""的字段
doAdd := func(temp string) []string {
defer func() {
if r := recover(); r != nil {
panic(r)
}
}()
strs := make([]string, 0)
for _, i := range gstr.Split(temp, ",") {
i = gstr.TrimAll(i)
if i == "" {
continue
}
begin := gstr.Split(i, ":")[0]
end := gstr.Split(i, ":")[1]
end = gstr.Replace(end, `"`, "")
strs = append(strs, fmt.Sprintf(`%s:"%s"`, begin, end))
}
return strs
}
temp := string(replace)
temp = temp[1 : len(temp)-1]
strs := make([]string, 0)
if !gstr.Contains(temp, `"options":`) {
strs = append(strs, doAdd(temp)...)
} else {
t := gstr.Split(temp, `"options":`)
strs = append(strs, doAdd(t[0])...)
t[1] = gstr.Replace(t[1], `"`, "")
t[1] = fmt.Sprintf(`"%s"`, t[1])
strs = append(strs, fmt.Sprintf(`"options":%s`, t[1]))
}
return fmt.Sprintf(`{%s}`, strings.Join(strs, ","))
}

```
2022-07-24 10:16:10 +08:00
回复了 idblife 创建的主题 Linux Linux 用了半个月还是逃回 macos 的几个疑问
服务器一般都是 linux ,平时自己也用 linux 感觉不错,有一种一直在线上的感觉。
2022-07-20 14:46:35 +08:00
回复了 andyJado 创建的主题 程序员 你最常用的 CLI(命令行工具)是什么?
1 642 22.5977% cd
2 578 20.3449% ls
3 432 15.2059% gf
4 126 4.43506% goland
5 111 3.90707% xgit.sh
6 102 3.59029% sh
7 95 3.34389% wps
8 83 2.92151% ll
9 50 1.75994% sudo
10 50 1.75994% d
1  2  3  4  5  6  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2696 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 22ms · UTC 11:33 · PVG 19:33 · LAX 04:33 · JFK 07:33
Developed with CodeLauncher
♥ Do have faith in what you're doing.