Created
July 30, 2018 16:37
-
-
Save jagroop/86606c9076d8c9d15364b7f3dfa56153 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script> | |
</head> | |
<body> | |
<div id="app"> | |
<ul v-for="(post, index) in posts"> | |
<li> | |
<div> | |
<p contenteditable="true" v-text="post.title" @input="updateContent(post.id, $event)"> | |
</p> | |
</div> | |
</li> | |
</ul> | |
</div> | |
<script> | |
var app = new Vue({ | |
el: '#app', | |
data() { | |
return { | |
posts: [ | |
{id: 1, title: 'flow', status: true}, | |
{id: 2, title: 'brother', status: true}, | |
{id: 3, title: 'shelter', status: true}, | |
{id: 4, title: 'slow', status: true}, | |
{id: 5, title: 'kids', status: true}, | |
{id: 6, title: 'announced', status: true}, | |
{id: 7, title: 'night', status: true}, | |
{id: 8, title: 'carry', status: true}, | |
{id: 9, title: 'shown', status: true} | |
] | |
} | |
}, | |
methods: { | |
updateContent(post_id, e) { | |
var content = e.target.innerHTML.replace(/^\|+|\|+$/g, ''); | |
console.log(content, post_id); | |
} | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment