Skip to content

Commit

Permalink
fsetup
Browse files Browse the repository at this point in the history
  • Loading branch information
vedees committed May 19, 2021
0 parents commit 7ce54ec
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
37 changes: 37 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const app = {
data() {
return {
title: "VTwitter",
item: "",
items: [
{
id: 1,
body: "hello vue 3",
avatar: `https://avatars.dicebear.com/api/male/1.svg`,
date: new Date(Date.now()).toLocaleString(),
},
{
id: 2,
body: "hello world",
avatar: `https://avatars.dicebear.com/api/male/2.svg`,
date: new Date(Date.now()).toLocaleString(),
},
],
};
},
methods: {
onSubmit() {
this.items.push({
id: Math.round(Math.random() * 30),
avatar: `https://avatars.dicebear.com/api/male/${Date.now()}.svg`,
body: this.item,
date: new Date(Date.now()).toLocaleString(),
});

// reset
this.item = "";
},
},
};

Vue.createApp(app).mount("#app");
33 changes: 33 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vue.js App</title>
<script src="https://unpkg.com/vue@next"></script>
</head>
<body>
<div id="app">
<h1>{{title}}</h1>

<form @submit.prevent="onSubmit">
<textarea
v-model="item"
required
placeholder="Type tweet here"
></textarea>
<br />
<button type="submit">Submit</button>
</form>
<ul>
<li v-for="tweet in items" key="tweet.id">
<img style="width: 30px; height: 30px" :src="tweet.avatar" />
<span>{{tweet.date}}</span>
<div>{{tweet.body}}</div>
</li>
</ul>
</div>
<script src="./app.js"></script>
</body>
</html>

0 comments on commit 7ce54ec

Please sign in to comment.