Skip to content

Commit ea55e04

Browse files
authored
New Crowdin updates (#109)
* New translations javascript-runtime.md (French) * New translations javascript-runtime.md (Portuguese) * New translations javascript-runtime.md (Chinese Simplified)
1 parent 8d398ca commit ea55e04

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

i18n/fr-FR/javascript-runtime.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ For example use `Page.Eval` to set global value:
1010
page.MustEval(`() => window.a = {name: 'jack'}`)
1111
```
1212

13-
We can use a js function to pass value as json arguments:
13+
We can use the arguments of the js function to receive golang variables, here's how we get the `key` and `data` from golang and set it to the page's window object `k`:
1414

1515
```go
1616
key := "a"
@@ -27,6 +27,12 @@ val := page.MustEval(`() => a`).Get("name").Str()
2727
fmt.Println(val) // output: jack
2828
```
2929

30+
`Eval` only accepts js function, code like below won't work:
31+
32+
```go
33+
page.MustEval(`a`) // will fail
34+
```
35+
3036
## Eval on an element
3137

3238
`Element.Eval` is similar with `Page.Eval`, but with the `this` object set to the current element. For example, we have a `<button>Submit</button>` on the page, we can read or modify the element with JS:

i18n/pt-PT/javascript-runtime.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Por exemplo, use `Page. Eval` para definir o valor global:
1010
page. MustEval(`() => window.a = {name: 'jack'}`)
1111
```
1212

13-
Podemos usar uma função js para passar valor como argumentos json:
13+
We can use the arguments of the js function to receive golang variables, here's how we get the `key` and `data` from golang and set it to the page's window object `k`:
1414

1515
```go
1616
chave := "a"
@@ -27,6 +27,12 @@ val := page. MustEval(`() => a`). Get("name"). Str()
2727
fmt. Println(val) // output: jack
2828
```
2929

30+
`Eval` only accepts js function, code like below won't work:
31+
32+
```go
33+
page.MustEval(`a`) // will fail
34+
```
35+
3036
## Eval on an element
3137

3238
`Element. Eval` is similar with `Page. Eval`, but with the `this` object set to the current element. For example, we have a `<button>Submit</button>` on the page, we can read or modify the element with JS:

i18n/zh-CN/javascript-runtime.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
page.MustEval(`() => window.a = {name: 'jack'}`)
1111
```
1212

13-
我们可以使用 js 函数来把值作为 json 参数传递:
13+
我们可以使用 js 函数的参数来获取 golang 变量, 这是如何从 golang 中获取 `key``data` 数据并将其设置为页面 window 上的对象 `k`
1414

1515
```go
1616
key := "a"
@@ -27,6 +27,12 @@ val := page.MustEval(`() => a`).Get("name").Str()
2727
fmt.Println(val) // output: jack
2828
```
2929

30+
`Eval` 只接受 js 函数,如下代码是无效的:
31+
32+
```go
33+
page.MustEval(`a`) // 将失败
34+
```
35+
3036
## 在元素上 eval
3137

3238
`Element.Eval``Page.Eval` 类似,但是对于前者来说,`this` 对象代表当前元素。 例如在页面上有一个 `<button>Submit</button>` ,我们可以用 JS 来读取或修改元素:

0 commit comments

Comments
 (0)