Vue Router GWT

Vue Router JsInterop classes to be used with Vue GWT.

License

License

Categories

Categories

GWT (Google Web Toolkit) User Interface Web Frameworks
GroupId

GroupId

com.axellience
ArtifactId

ArtifactId

vue-router-gwt
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

gwt-lib
Description

Description

Vue Router GWT
Vue Router JsInterop classes to be used with Vue GWT.
Project URL

Project URL

https://github.com/VueGWT/vue-router-gwt
Source Code Management

Source Code Management

https://github.com/VueGWT/vue-router-gwt/tree/master

Download vue-router-gwt

Dependencies

compile (1)

Group / Artifact Type Version
com.axellience : vue-gwt Optional jar 1.0.1

import (1)

Group / Artifact Type Version
com.google.gwt : gwt pom 2.9.0

Project Modules

There are no modules declared in this project.

Vue Router GWT

A JsInterop wrapper for Vue Router to use in Vue GWT.

This wrapper allows you to use Vue Router in Vue GWT apps.

How to Set It Up

Make sure you have set up your Vue GWT project.

Then follow these steps:

Add the Maven Dependency

<project>
    <dependencies>
        ...
        <dependency>
            <groupId>com.axellience</groupId>
            <artifactId>vue-router-gwt</artifactId>
            <version>1.0.0</version>
        </dependency>
    </dependencies>
</project>

Add the GWT dependency

Add this in your app .gwt.xml file:

<inherits name='com.axellience.vueroutergwt.VueRouterGwt'/>

Call VueRouter.init()

This will inject the javascript of VueRouter in your page. You should do it right under your Vue.init().

VueGWT.init();
VueRouter.init();

If you already have the VueRouter javascript included in your page by another way, you don't have to call VueRouter.init().

How to Use It

Let's see a simple example. We have an application with a RootComponent and we want to set up routing for two Components: FooComponent and BarComponent.

Foo and Bar Components

FooComponent

@Component
public class FooComponent implements IsVueComponent {
}
<div>Hello from Foo!</div>

BarComponent

@Component
public class BarComponent implements IsVueComponent {
}
<div>Hello from Bar!</div>

RootComponent

Ok this Component is going to be a little more interesting.

<div>
    <h1>Hello App!</h1>
    <p>
        <router-link to="/foo">Go to Foo</router-link>
        <router-link to="/bar">Go to Bar</router-link>
    </p>
    <router-view></router-view>
</div>

router-link Components above in the template will be replaced by a elements at runtime. router-view will contain the Component for the active route (either FooComponent or BarComponent).

Let's see how we declare our routes:

// First, we declare a class to configure the routing and register it on some component options
public class RoutesConfig implements CustomizeOptions {
    @Override
    public void customizeOptions(VueComponentOptions vueComponentOptions)
    {
        // We first create an object to hold our Router options
        RouterOptions routerOptions = new RouterOptions();
        
        // We add the routes to our options by passing
        // their path and the Constructor of the Component we want to display on them
        routerOptions
            .addRoute("/foo", FooComponentFactory.get())
            .addRoute("/bar", BarComponentFactory.get());

        // We the create our router
        VueRouter vueRouter = new VueRouter(routerOptions);
        
        // And set it on our Component options
        vueComponentOptions.set("router", vueRouter);
    }
}
// Then we bind this class to our RootComponent so it customize it's options
@Component(customizeOptions = RoutesConfig.class)
public class RootComponent implements IsVueComponent {
}

Easy, right?

If you want more documentation on the API you can checkout the official Vue Router documentation.

Who Made This?

Vue GWT is developed by the awesome people at
GenMyModel

com.axellience

Vue GWT

Vue.js Components/Custom Elements in Java with GWT

Versions

Version
1.0.1
1.0.0
1.0-beta-9
1.0-beta-8
1.0-beta-7
1.0-beta-6
1.0-beta-5
1.0-beta-4
1.0-beta-3
1.0-beta-2
1.0-beta-1