A Pen by Johan Kohlin on CodePen.
Last active
April 10, 2018 22:58
-
-
Save Magistern/6d5e5fd4d5fef938e29852318a17b3c7 to your computer and use it in GitHub Desktop.
A simple vue app
This file contains hidden or 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
<div id="app"> | |
<input v-model="foo"> + | |
<input v-model="bar"> = | |
<span>{{foo}} {{bar}}</span> | |
<hr> | |
<input v-model.number="baz" type="number"> + | |
<input v-model.number="qux" type="number"> = | |
<span>{{baz + qux}}</span> | |
</div> | |
<!-- | |
v-model=baz connects the Vue data property baz to the input's value attribute | |
v-model.number=baz converts the string to a number before saving it to the Vue data property baz | |
The moustaches {{ }} are template markers for Vue data. You can add logic and arithmetics as well | |
--> |
This file contains hidden or 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
// The Vue constructor comes from the vue.js file | |
var app = new Vue({ | |
el:'#app', | |
data:{ | |
foo:"hello", | |
bar:"world", | |
baz:2, | |
qux:3 | |
} | |
}); |
This file contains hidden or 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
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.3.4/vue.min.js"></script> |
This file contains hidden or 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
#app { margin-top:20px; text-align:center; font-size:2em; } | |
input{ width:4em; font-family:monospace; } | |
input[type=number]{ width:2em; } |
This file contains hidden or 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
<link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.4.2/css/bulma.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment