Skip to content

Commit 20f3a82

Browse files
committed
Update to VueJS 2 API
1 parent 1ae32cf commit 20f3a82

File tree

2 files changed

+55
-128
lines changed

2 files changed

+55
-128
lines changed

option.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,27 @@ type Option struct {
125125
// into the parent’s $children array.
126126
Parent *js.Object `js:"parent"`
127127

128+
// delimiters
129+
//
130+
// Type: Array<string>
131+
//
132+
// default: ["{{", "}}"]
133+
//
134+
// Details:
135+
//
136+
// Change the plain text interpolation delimiters.
137+
// This option is only available in the standalone build.
138+
Delimiters []string `js:"delimiters"`
139+
140+
// functional
141+
// Type: boolean
142+
// Details:
143+
// Causes a component to be stateless (no data) and
144+
// instanceless (no this context).
145+
// They are simply a render function that returns virtual nodes
146+
// making them much cheaper to render.
147+
Functional []string `js:"functional"`
148+
128149
// map to sub component
129150
coms map[string]*Component
130151
// properties

vue.go

Lines changed: 34 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,15 @@ type ViewModel struct {
108108
// The direct child components of the current instance.
109109
Children *js.Object `js:"$children"`
110110

111+
// vm.$slots
112+
// Type: { [name: string]: ?Array<VNode> }
113+
// Read only
114+
// Details:
115+
// Used to programmatically access content distributed by slots.
116+
// Each named slot has its own corresponding property
117+
// Accessing vm.$slots is most useful when writing a component with a render function.
118+
Slots *js.Object `js:"$slots"`
119+
111120
// vm.$refs
112121
// Type: Object
113122
// Read only
@@ -118,13 +127,12 @@ type ViewModel struct {
118127
// v-ref.
119128
Refs *js.Object `js:"$refs"`
120129

121-
// vm.$els
122-
// Type: Object
123-
// Read only
130+
// vm.$isServer
131+
// Type: boolean
132+
// Read only
124133
// Details:
125-
// An object that holds DOM elements that have v-el registered.
126-
// See also: v-el.
127-
Els *js.Object `js:"$els"`
134+
// Whether the current Vue instance is running on the server.
135+
IsServer bool `js:"$isServer"`
128136

129137
// vm.$watch( expression, callback, [deep, immediate] )
130138
// expression String
@@ -139,79 +147,20 @@ type ViewModel struct {
139147
deepWatch bool,
140148
) (unwatcher func()) `js:"$watch"`
141149

142-
// vm.$eval( expression )
143-
// expression String
144-
// Evaluate an expression that can also contain filters.
145-
// assuming vm.msg = 'hello'
146-
// vm.$eval('msg | uppercase') // -> 'HELLO'
147-
Eval func(expression string) *js.Object `js:"$eval"`
148-
149150
// vm.$set( keypath, value )
150151
// keypath String
151152
// value *
152153
// Set a data value on the Vue instance given a valid keypath.
153154
// If the path doesn’t exist it will be created.
154155
Set func(keypath string, val interface{}) `js:"$set"`
155156

156-
// vm.$add( keypath, value )
157-
//
158-
// keypath String
159-
// value *
160-
// Add a root level property to the Vue instance (and also its $data).
161-
// Due to the limitations of ES5, Vue cannot detect properties directly
162-
// added to or deleted from an Object,
163-
// so use this method and vm.$delete when you need to do so. Additionally,
164-
// all observed objects are augmented with these two methods too.
165-
Add func(keypath string, val interface{}) `js:"$add"`
166-
167157
// vm.$delete( keypath )
168158
// keypath String
169159
// Delete a root level property on the Vue instance (and also its $data).
170160
Delete func(keypath string) `js:"$delete"`
171161

172-
// vm.$interpolate( templateString )
173-
// templateString String
174-
// Evaluate a piece of template string containing
175-
// mustache interpolations.
176-
// Note that this method simply performs string interpolation;
177-
// attribute directives are not compiled.
178-
//
179-
// // assuming vm.msg = 'hello'
180-
// vm.$interpolate('{{msg}} world!') // -> 'hello world!'
181-
Interpolate func(templateString string) `js:"$interpolate"`
182-
183162
////////////////////////////////// Events
184163

185-
// Each vm is also an event emitter.
186-
// When you have multiple nested ViewModels,
187-
// you can use the event system to communicate between them.
188-
//
189-
// vm.$dispatch( event, [args…] )
190-
// event String
191-
// args… optional
192-
//
193-
// Dispatch an event from the current vm that propagates
194-
// all the way up to its $root. If a callback returns false,
195-
// it will stop the propagation at its owner instance.
196-
Dispatch func(event string, args ...interface{}) `js:"$dispatch"`
197-
198-
// vm.$broadcast( event, [args…] )
199-
// event String
200-
// args… optional
201-
//
202-
// Emit an event to all children vms of the current vm,
203-
// which gets further broadcasted to their children all the way down.
204-
// If a callback returns false, its owner instance will not broadcast
205-
// the event any further.
206-
Broadcast func(event string, args ...interface{}) `js:"$broadcast"`
207-
208-
// vm.$emit( event, [args…] )
209-
// event String
210-
// args… optional
211-
//
212-
// Trigger an event on this vm only.
213-
Emit func(event string, args ...interface{}) `js:"$emit"`
214-
215164
// vm.$on( event, callback )
216165
// event String
217166
// callback Function
@@ -236,35 +185,12 @@ type ViewModel struct {
236185
// remove that specific callback only.
237186
Off func(event ...string) `js:"$off"`
238187

239-
// DOM
240-
// All vm DOM manipulation methods work like their jQuery counterparts -
241-
// except they also trigger Vue.js transitions if there are any declared
242-
// on vm’s $el. For more details on transitions
243-
// see Adding Transition Effects.
244-
245-
// vm.$appendTo( element|selector, [callback] )
246-
// element HTMLElement | selector String
247-
// callback Function optional
248-
// Append the vm’s $el to target element. The argument can be either
249-
// an element or a querySelector string.
250-
AppendTo func(elementOrselector string) `js:"$appendTo"`
251-
252-
// vm.$before( element|selector, [callback] )
253-
// element HTMLElement | selector String
254-
// callback Function optional
255-
// Insert the vm’s $el before target element.
256-
Before func(elementOrselector string) `js:"$before"`
257-
258-
// vm.$after( element|selector, [callback] )
259-
// element HTMLElement | selector String
260-
// callback Function optional
261-
// Insert the vm’s $el after target element.
262-
After func(elementOrselector string) `js:"$after"`
263-
264-
// vm.$remove( [callback] )
265-
// callback Function optional
266-
// Remove the vm’s $el from the DOM.
267-
Remove func() `js:"$remove"`
188+
// vm.$emit( event, [args…] )
189+
// event String
190+
// args… optional
191+
//
192+
// Trigger an event on this vm only.
193+
Emit func(event string, args ...interface{}) `js:"$emit"`
268194

269195
///////////////////// Lifecycle
270196

@@ -279,47 +205,27 @@ type ViewModel struct {
279205
// instance methods after it.
280206
Mount func(elementOrselector ...interface{}) *js.Object `js:"$mount"`
281207

208+
// vm.$forceUpdate()
209+
// Usage:
210+
// Force the Vue instance to re-render.
211+
// Note it does not affect all child components,
212+
// only the instance itself and child components with inserted slot content.
213+
ForceUpdate func() `js:"$forceUpdate"`
214+
215+
// vm.$nextTick( [callback] )
216+
// Arguments:
217+
// {Function} [callback]
218+
// Usage:
219+
// Defer the callback to be executed after the next DOM update cycle. Use it immediately after you’ve changed some data to wait for the DOM update. This is the same as the global Vue.nextTick, except that the callback’s this context is automatically bound to the instance calling this method.
220+
NextTick func(cb func()) `js:"$nextTick"`
221+
282222
// vm.$destroy( [remove] )
283223
// remove Boolean optional
284224
// Completely destroy a vm.
285225
// Clean up its connections with other existing vms,
286226
// unbind all its directives and remove its $el from the DOM.
287227
// Also, all $on and $watch listeners will be automatically removed.
288228
Destroy func(remove bool) `js:"$destroy"`
289-
290-
// vm.$addChild( [options, constructor] )
291-
// options Object optional
292-
// constructor Function optional
293-
//
294-
// Adds a child instance to the current instance.
295-
// The options object is the same in manually instantiating an instance.
296-
// Optionally you can pass in a constructor created from Vue.extend().
297-
//
298-
// There are three implications of
299-
// a parent-child relationship between instances:
300-
// The parent and child can communicate via the event system.
301-
// The child has access to all parent assets (e.g. custom directives).
302-
// The child, if inheriting parent scope,
303-
// has access to parent scope data properties.
304-
AddChild func(options js.M) `js:"$addChild"`
305-
306-
// vm.$log( [keypath] )
307-
//
308-
// keypath String optional
309-
// Log the current instance data as a plain object, which is more
310-
// console-inspectable than a bunch of getter/setters.
311-
// Also accepts an optional key.
312-
//
313-
// vm.$log() // logs entire ViewModel data
314-
// vm.$log('item') // logs vm.item
315-
Log func(keypath ...interface{}) `js:"$log"`
316-
317-
// Defer the callback to be executed after the next DOM update cycle.
318-
// Use it immediately after you’ve changed some data to
319-
// wait for the DOM update. This is the same as the global
320-
// Vue.nextTick, except that the callback’s this context is
321-
// automatically bound to the instance calling this method.
322-
NextTick func(cb func()) `js:"$nextTick"`
323229
}
324230

325231
// New creates a VueJS Instance to apply bidings between `structPtr` and

0 commit comments

Comments
 (0)