Skip to content

Instantly share code, notes, and snippets.

@CHUKK
Created Jun 3, 2018
Embed
What would you like to do?
calculator app
<div class="wrap">
<h1>calculator</h1>
<div class="calc">
<p>税抜: <input v-model="price" type="number"></p>
<p>税込: <input v-model="withTax" type="number"></p>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
new Vue({
el: '.calc',
data: {
price: '100'
},
computed: {
withTax: {
get: function () {
return parseInt(this.price * 1.08)
},
set: function (value) {
this.price = Math.ceil(value / 1.08);
}
}
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment