Reactivity
Declare state
Vue 2
<script>
export default {
data() {
return {
name: "John",
};
},
};
</script>
<template>
<h1>Hello {{ name }}</h1>
</template>
Aurelia 1
<template>
<h1>Hello ${name}</h1>
</template>
Update state
Vue 2
<script>
export default {
data() {
return {
name: "John",
};
},
created() {
this.name = "Jane";
},
};
</script>
<template>
<h1>Hello {{ name }}</h1>
</template>
Aurelia 1
<template>
<h1>Hello ${name}</h1>
</template>
Computed state
Vue 2
<script>
export default {
data() {
return {
count: 10,
};
},
computed: {
doubleCount() {
return this.count * 2;
},
},
};
</script>
<template>
<div>{{ doubleCount }}</div>
</template>
Aurelia 1
<template>
<div>${doubleCount}</div>
</template>
Templating
Minimal template
Vue 2
<template>
<h1>Hello world</h1>
</template>
Aurelia 1
<template>
<h1>Hello world</h1>
</template>
Styling
Vue 2
<template>
<div>
<h1 class="title">I am red</h1>
<button style="font-size: 10rem">I am a button</button>
</div>
</template>
<style scoped>
.title {
color: red;
}
</style>
Aurelia 1
.title {
color: red;
}
Loop
Vue 2
<script>
export default {
data() {
return {
colors: ["red", "green", "blue"],
};
},
};
</script>
<template>
<ul>
<li v-for="color in colors" :key="color">
{{ color }}
</li>
</ul>
</template>
Aurelia 1
<template>
<ul>
<li repeat.for="color of colors">${color}</li>
</ul>
</template>
Event click
Vue 2
<script>
export default {
data() {
return {
count: 0,
};
},
methods: {
incrementCount() {
this.count++;
},
},
};
</script>
<template>
<div>
<p>Counter: {{ count }}</p>
<button @click="incrementCount">+1</button>
</div>
</template>
Aurelia 1
<template>
<p>Counter: ${count}</p>
<button click.trigger="incrementCount()">+1</button>
</template>
Dom ref
Vue 2
<script>
export default {
mounted() {
this.$refs.inputElement.focus();
},
};
</script>
<template>
<input ref="inputElement" />
</template>
Aurelia 1
<template>
<input ref="inputElement" />
</template>
Conditional
Vue 2
<script>
export default {
data() {
return {
TRAFFIC_LIGHTS: ["red", "orange", "green"],
lightIndex: 0,
};
},
computed: {
light() {
return this.TRAFFIC_LIGHTS[this.lightIndex];
},
},
methods: {
nextLight() {
this.lightIndex = (this.lightIndex + 1) % this.TRAFFIC_LIGHTS.length;
},
},
};
</script>
<template>
<div>
<button @click="nextLight">Next light</button>
<p>Light is: {{ light }}</p>
<p>
You must
<span v-if="light === 'red'">STOP</span>
<span v-else-if="light === 'orange'">SLOW DOWN</span>
<span v-else-if="light === 'green'">GO</span>
</p>
</div>
</template>
Aurelia 1
<template>
<button click.trigger="nextLight()">Next light</button>
<p>Light is: ${light}</p>
<p>
You must
<span if.bind="light === 'red'">STOP</span>
<span if.bind="light === 'orange'">SLOW DOWN</span>
<span if.bind="light === 'green'">GO</span>
</p>
</template>
Lifecycle
On mount
Vue 2
<script>
export default {
data() {
return {
pageTitle: "",
};
},
mounted() {
this.pageTitle = document.title;
},
};
</script>
<template>
<p>Page title: {{ pageTitle }}</p>
</template>
Aurelia 1
<template>
<p>Page title is: ${pageTitle}</p>
</template>
On unmount
Vue 2
<script>
export default {
data() {
return {
time: new Date().toLocaleTimeString(),
timer: null,
};
},
mounted() {
this.timer = setInterval(() => {
this.time = new Date().toLocaleTimeString();
}, 1000);
},
beforeDestroy() {
clearInterval(this.timer);
},
};
</script>
<template>
<p>Current time: {{ time }}</p>
</template>
Aurelia 1
<template>
<p>Current time: ${time}</p>
</template>
Component composition
Props
Vue 2
<script>
import UserProfile from "./UserProfile.vue";
export default {
components: {
UserProfile,
},
};
</script>
<template>
<UserProfile
name="John"
:age="20"
:favorite-colors="['green', 'blue', 'red']"
is-available
/>
</template>
Aurelia 1
<template>
<require from="./user-profile"></require>
<user-profile
name.bind="name"
age.bind="age"
favourite-colors.bind="colors"
is-available.bind="available"
></user-profile>
</template>
Emit to parent
Vue 2
<script>
import AnswerButton from "./AnswerButton.vue";
export default {
components: {
AnswerButton,
},
data() {
return {
isHappy: true,
};
},
methods: {
onAnswerNo() {
this.isHappy = false;
},
onAnswerYes() {
this.isHappy = true;
},
},
};
</script>
<template>
<div>
<p>Are you happy?</p>
<AnswerButton @yes="onAnswerYes" @no="onAnswerNo" />
<p style="font-size: 50px">
{{ isHappy ? "😀" : "😥" }}
</p>
</div>
</template>
Aurelia 1
<template>
<require from="./answer-button"></require>
<p>Can I come ?</p>
<answer-button action-handler.call="handleAnswer(reply)"></answer-button>
<p style="font-size: 50px">${isHappy ? "😀" : "😥"}</p>
</template>
Slot
Vue 2
<script>
import FunnyButton from "./FunnyButton.vue";
export default {
components: {
FunnyButton,
},
};
</script>
<template>
<FunnyButton> Click me! </FunnyButton>
</template>
Aurelia 1
<template>
<require from="./funny-button"></require>
<funny-button>Click me !</funny-button>
</template>
Slot fallback
Vue 2
<script>
import FunnyButton from "./FunnyButton.vue";
export default {
components: {
FunnyButton,
},
};
</script>
<template>
<div>
<FunnyButton />
<FunnyButton> I got content! </FunnyButton>
</div>
</template>
Aurelia 1
<template>
<require from="./funny-button"></require>
<funny-button></funny-button>
<funny-button>Click me !</funny-button>
</template>
Context
Vue 2
<script>
import UserProfile from "./UserProfile.vue";
export default {
components: { UserProfile },
provide() {
return {
user: Object.assign(this.user, {
updateUsername: this.updateUsername,
}),
};
},
data() {
return {
user: {
id: 1,
username: "unicorn42",
email: "[email protected]",
},
};
},
methods: {
updateUsername(newUsername) {
this.user.username = newUsername;
},
},
};
</script>
<template>
<div>
<h1>Welcome back, {{ user.username }}</h1>
<UserProfile />
</div>
</template>
Aurelia 1
Missing snippet Help us to improve Component Party 
Form input
Input text
Vue 2
<script>
export default {
data() {
return {
text: "Hello World",
};
},
};
</script>
<template>
<div>
<p>{{ text }}</p>
<input v-model="text" />
</div>
</template>
Aurelia 1
<template>
<p>${text}</p>
<input value.bind="text" />
</template>
Checkbox
Vue 2
<script>
export default {
data() {
return {
isAvailable: true,
};
},
};
</script>
<template>
<div>
<input id="is-available" v-model="isAvailable" type="checkbox" />
<label for="is-available">Is available</label>
</div>
</template>
Aurelia 1
<template>
<input id="is-available" type="checkbox" checked.bind="isAvailable" />
<label for="is-available">Is available</label>: ${isAvailable}
</template>
Radio
Vue 2
<script>
export default {
data() {
return {
picked: "red",
};
},
};
</script>
<template>
<div>
<div>Picked: {{ picked }}</div>
<input id="blue-pill" v-model="picked" type="radio" value="blue" />
<label for="blue-pill">Blue pill</label>
<input id="red-pill" v-model="picked" type="radio" value="red" />
<label for="red-pill">Red pill</label>
</div>
</template>
Aurelia 1
<template>
<div>Picked: ${picked}</div>
<input id="blue-pill" checked.bind="picked" type="radio" value="blue" />
<label for="blue-pill">Blue pill</label>
<input id="red-pill" checked.bind="picked" type="radio" value="red" />
<label for="red-pill">Red pill</label>
</template>
Select
Vue 2
<script>
export default {
data() {
return {
selectedColorId: 2,
colors: [
{ id: 1, text: "red" },
{ id: 2, text: "blue" },
{ id: 3, text: "green" },
{ id: 4, text: "gray", isDisabled: true },
],
};
},
};
</script>
<template>
<select v-model="selectedColorId">
<option
v-for="color in colors"
:key="color.id"
:value="color.id"
:disabled="color.isDisabled"
>
{{ color.text }}
</option>
</select>
</template>
Aurelia 1
<template>
<select value.bind="selectedColorId">
<option value="">Select A Color</option>
<option
repeat.for="color of colors"
value.bind="color.id"
disabled.bind="color.isDisabled"
>
${color.text}
</option>
</select>
</template>
Webapp features
Render app
Vue 2
<!doctype html>
<html>
<body>
<div id="app"></div>
<script type="module" src="./main.js"></script>
</body>
</html>
Aurelia 1
Missing snippet Help us to improve Component Party 
Fetch data
Vue 2
<script>
export default {
data() {
return {
isLoading: false,
error: undefined,
users: undefined,
};
},
mounted() {
this.fetchData();
},
methods: {
async fetchData() {
this.isLoading = true;
try {
const response = await fetch("https://randomuser.me/api/?results=3");
const { results: users } = await response.json();
this.users = users;
this.error = undefined;
} catch (error) {
this.error = error;
} finally {
this.users = undefined;
this.isLoading = false;
}
},
},
};
</script>
<template>
<p v-if="isLoading">Fetching users...</p>
<p v-else-if="error">An error ocurred while fetching users</p>
<ul v-else-if="users">
<li v-for="user in users" :key="user.login.uuid">
<img :src="user.picture.thumbnail" alt="user" />
<p>
{{ user.name.first }}
{{ user.name.last }}
</p>
</li>
</ul>
</template>
Aurelia 1
<template>
<p if.bind="isLoading">Fetching users...</p>
<p if.bind="error">An error ocurred while fetching users</p>
<ul if.bind="users">
<li repeat.for="user of users">
<img src.bind="user.picture.thumbnail" alt="user" />
<p>${ user.name.first } ${ user.name.last }</p>
</li>
</ul>
</template>