Skip to content

Commit da3448e

Browse files
committed
using v.Object.Set in ViewModel.FromJS
1 parent 633eed7 commit da3448e

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

examples/features/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
</li>
3838
<input v-model="str" />
3939
<br>
40+
wtf: {{wtf}}
41+
<br>
4042
Todos:<br>
4143
<ul v-for="todo in todos">
4244
<li>{{todo.time }} - {{todo.content}}</li>

mapping.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package vue
22

33
import (
4-
"github.com/Archs/js/JSON"
5-
"github.com/gopherjs/gopherjs/js"
64
"strings"
5+
6+
"github.com/gopherjs/gopherjs/js"
7+
"github.com/oskca/gopherjs-json"
78
)
89

910
// FromJS set the corresponding VueJS data model field from obj
@@ -14,13 +15,13 @@ func (v *ViewModel) FromJS(obj *js.Object) *ViewModel {
1415
if strings.HasPrefix(key, "$") || strings.HasPrefix(key, "_") {
1516
continue
1617
}
17-
v.Set(key, obj.Get(key))
18+
v.Object.Set(key, obj.Get(key))
1819
}
1920
return v
2021
}
2122

2223
func (v *ViewModel) FromJSON(jsonStr string) *ViewModel {
23-
return v.FromJS(JSON.Parse(jsonStr))
24+
return v.FromJS(json.Parse(jsonStr))
2425
}
2526

2627
func (v *ViewModel) ToJS() *js.Object {
@@ -36,5 +37,5 @@ func (v *ViewModel) ToJS() *js.Object {
3637
}
3738

3839
func (v *ViewModel) ToJSON() string {
39-
return JSON.Stringify(v.ToJSON())
40+
return json.Stringify(v.ToJSON())
4041
}

0 commit comments

Comments
 (0)