Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/mbdavid/DotVue

Implement .vue file handler in .NET with server ViewModel postback
https://github.com/mbdavid/DotVue

Last synced: about 1 month ago
JSON representation

Implement .vue file handler in .NET with server ViewModel postback

Lists

README

        

# DotVue

Implement `.vue` single-file component with server-side ViewModel. Use all power of VueJS with simple C# server side data access.

> Login.vue.cs

```C#
namespace ServerViewModel
{
public class Login : ViewModel
{
public Username { get; set; }
public Password { get; set; }

public Message { get; set; }

public void Login()
{
this.Message = AuthServie.Login(Username, Password);
}
}
}
```

> Login.vue

```HTML
@viewmodel ServerViewModel.Login


.login-box {
border: 1px solid silver;
button { display: block; }
}

.alert {
color: red;
}

// Optional: add Vue mixin (client only)
return {
methods: {
Clear: function() {
this.Username = "";
this.Password = "";
this.Message = "";
}
}
}

```

## Setup

```C#
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseDefaultFiles();
app.UseStaticFiles();

app.UseDotVue(c =>
{
c.AddAssembly(typeof(Startup).Assembly);
});
}
```

# Features

- ASP.NET Core 2
- Server based ViewModel with attributes decorations: methods, watchs and props
- Deploy `.vue` file as embedded resource (deploy only `.dll` file)
- Support file upload
- Support any external vue plugin

- See `WebApp` for examples