createApp()

Create Vue apps with less JS

Features

Other differences from Vue’s createApp()

Examples

<div id="app">
	<input type=number v-model=foo> + 1 = {{ foo + 1 }}
</div>
<script type="module">
import { createApp } from "https://mavue.mavo.io/mavue.js";

let app = createApp({
	data: {
		foo: 1
	}
});
</script>

Using element and expose options:

<div id="app2">
	<button @click="alert(foo++)">alert(foo++)</button>
	<button @click="console.log(foo--)">console.log(foo--)</button>
	{{ math.round(foo * 10 / 3)/10 }}
</div>
<script type="module">
import { createApp } from "https://mavue.mavo.io/mavue.js";

let app = createApp({
	element: "#app2",
	data: {
		foo: 1
	},
	expose: {console, alert, math: Math}
});
</script>

Note: Any functions you expose will be bound to the global scope. If that is not desirable, you can .bind() it yourself to a different context.

Installation

You can import createApp() either from the main MaVue file, or from the create-app subdirectory.

// Named import
import { createApp } from "https://mavue.mavo.io/mavue.js";
// Notice here it's a default import
import createApp from "https://mavue.mavo.io/create-app/index.js";