2017年3月28日 星期二

(vue.js).......

    <div id="test_1">
        <form id="form_1">
            <p>
                price:<input name="price" type="text" v-model="price">
            </p>
            <p>
                cents: <span>{{cents}}</span>
            </p>
        </form>
    </div>
</body>
<script>
    var test_1VM = new Vue({
        el: '#test_1',
        data: {
            cents: 100
        },
        computed: {
            price: {
                setfunction(newValue) {
                    this.cents = newValue * 100;
                },
                getfunction() {
                    return (this.cents / 100);
                }
            }
        }
    });
</script>