All Projects → oskca → Gopherjs Vue

oskca / Gopherjs Vue

Licence: mit
VueJS bindings for gopherjs

Programming Languages

javascript
184084 projects - #8 most used programming language
go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Gopherjs Vue

Gopherjs Electron
Gopherjs bindings for Electron with an API translator.
Stars: ✭ 26 (-81.69%)
Mutual labels:  gopherjs, bindings
Vsphere Automation Sdk Java
Java samples, language bindings, and API reference documentation for vSphere, VMC, and NSX-T using the VMware REST API
Stars: ✭ 132 (-7.04%)
Mutual labels:  bindings
Pybind11
This project was created by Wenzel Jakob. Significant features and/or improvements to the code were contributed by Jonas Adler, Lori A. Burns, Sylvain Corlay, Eric Cousineau, Aaron Gokaslan, Ralf Grosse-Kunstleve, Trent Houliston, Axel Huebl, @hulucc, Yannick Jadoul, Sergey Lyskov Johan Mabille, Tomasz Miąsko, Dean Moldovan, Ben Pritchard, Jason Rhinelander, Boris Schäling, Pim Schellart, Henry Schreiner, Ivan Smirnov, Boris Staletic, and Patrick Stewart.
Stars: ✭ 10,158 (+7053.52%)
Mutual labels:  bindings
Nuklear Nim
Nim bindings for https://github.com/vurtun/nuklear/
Stars: ✭ 109 (-23.24%)
Mutual labels:  bindings
Samsung Trustzone Research
Reverse-engineering tools and exploits for Samsung's implementation of TrustZone
Stars: ✭ 85 (-40.14%)
Mutual labels:  bindings
Gir
Tool to generate rust bindings and user API for glib-based libraries
Stars: ✭ 124 (-12.68%)
Mutual labels:  bindings
Fruity
Rusty bindings for Apple libraries
Stars: ✭ 72 (-49.3%)
Mutual labels:  bindings
Gintro
High level GObject-Introspection based GTK3/GTK4 bindings for Nim language
Stars: ✭ 141 (-0.7%)
Mutual labels:  bindings
Fftw.jl
Julia bindings to the FFTW library for fast Fourier transforms
Stars: ✭ 127 (-10.56%)
Mutual labels:  bindings
Python Pulse Control
Python high-level interface and ctypes-based bindings for PulseAudio (libpulse)
Stars: ✭ 104 (-26.76%)
Mutual labels:  bindings
Gu
A web ui library for Go. [DEPRECATED]
Stars: ✭ 102 (-28.17%)
Mutual labels:  gopherjs
Grpcweb Example
An example implementation of a GopherJS client and a Go server using the Improbable gRPC-Web implementation
Stars: ✭ 85 (-40.14%)
Mutual labels:  gopherjs
Rust Gsl
A GSL (the GNU Scientific Library) binding for Rust
Stars: ✭ 125 (-11.97%)
Mutual labels:  bindings
Vdom
A virtual dom implementation written in go which is compatible with gopherjs
Stars: ✭ 83 (-41.55%)
Mutual labels:  gopherjs
Wlroots Rs
Attempt at safe Rust bindings for wlroots
Stars: ✭ 135 (-4.93%)
Mutual labels:  bindings
Sqlite
Interface to SQLite
Stars: ✭ 74 (-47.89%)
Mutual labels:  bindings
Humble
The main repository for Humble. Issues and new feature requests not related to any specific sub-packages go here.
Stars: ✭ 92 (-35.21%)
Mutual labels:  gopherjs
Lambda Lantern
🧙 ‎‎ A 3D game about functional programming patterns. Uses PureScript Native, C++, and Panda3D.
Stars: ✭ 122 (-14.08%)
Mutual labels:  bindings
Glua
Maybe you should use https://github.com/fiatjaf/flua instead of this
Stars: ✭ 142 (+0%)
Mutual labels:  gopherjs
Dotherside
C language library for creating bindings for the Qt QML language
Stars: ✭ 140 (-1.41%)
Mutual labels:  bindings

gopherjs-vue

VueJS bindings for gopherjs

Usage

Combined the power of Gopherjs and VueJS, you can use golang struct to provide the two-way data-binding context for VueJS, and easily implements the popular browser MVVM models in Go.

Currently ViewModel/Component/Directive/Filter are supported and wrapped in a gopherjs friendly way.

These are the basic rules to use this package:

  • all exported fields of the golang struct would become VueJS Instance's data which can be used in the html to do data binding: v-bind, etc

  • all exported funcs of the golang struct would become VueJS Instance's methods which can be called as html event handler: v-on, etc

  • the golang struct talked above is actually of pointer type and should have an anonymous embeded *js.Object field and the exported fields should have proper js struct tag for bidirectionaly data bindings

Using the debug|dev version of VueJS

This package includes the minified|product version of VueJS code by default, if you want to include the debug|dev version of of VueJS code, please specify buidling tags debug to the gopherjs build cmd as this:

gopherjs build --tags debug main.go

for more details please see the examples.

Basic example

gopherjs code:

package main

import (
    "github.com/gopherjs/gopherjs/js"
    "github.com/oskca/gopherjs-vue"
)

type Model struct {
    *js.Object        // this is needed for bidirectional data bindings
    IntValue   int    `js:"integer"`
    Str        string `js:"str"`
}

// this would be recognized as Inc in html
func (m *Model) Inc() {
    m.IntValue += 1
    println("inc called")
}

// this would be recognized as Repeat in html
func (m *Model) Repeat() {
    m.Str = m.Str + m.Str
}

// this would be recognized as Reset in html
func (m *Model) Reset() {
    m.Str = "a string "
}

func main() {
    m := &Model{
        Object: js.Global.Get("Object").New(),
    }
    // field assignment is required in this way to make data passing works
    m.IntValue = 100
    m.Str = "a string"
    // create the VueJS viewModel using a struct pointer
    vue.New("#app", m)
}

html markup:

<!DOCTYPE html>
<html>

<body>
    <div id="app" v-cloak>
        <div>integer: {{ integer }}
            <input v-model="integer"></input>
        </div>
        <div>str: {{ str }} </div>
        <button v-on:click="Inc">Increase</button>
        <button v-on:click="Repeat">Repeat</button>
        <button v-on:click="Reset">Reset</button>
    </div>
    <script type="text/javascript" src="basic.js"></script>
</body>

</html>

compile and run, then there you are :)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].