Vue.js_getter and setter

Posted YanEr、

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Vue.js_getter and setter相关的知识,希望对你有一定的参考价值。

<div id="test2">
        <input type="text" v-model="message" /><span>请输入您的姓名和电话号码,中间用“,”分隔</span>
        <p>{{info}}</p>
    </div>
    <script>
        var test2 = new Vue({
            el: "#test2",
            data: {
                message: "leona,18085558666",
            },
            computed: {
                info: {
                    get: function () {
                        var newMessage = this.message.split(",");
                        return "您的姓名是:" + newMessage[0] + "\r\n您的电话号码是:" + newMessage[newMessage.length-1];
                    },
                    set: function (newVal) {
                        this.message = newMessage;
                    }
                }
            }
        })
    </script>

computed 计算属性:

get 读取

set 写入

以上是关于Vue.js_getter and setter的主要内容,如果未能解决你的问题,请参考以下文章

Intellij IDEA 自定义 getter and setter

使用myeclipse的时候generate getters and setters出错

R 作业代写代编代码Thinking and Reasoning

The confusion about jsp four scopes and ServletContext,HttpSession,HttpServletReqest,PageContext(示例代

错误记录安卓 RecyclerView 报错 ( only use immediately and call holder.getAdapterPosition() to look it up )(代

ICM Technex 2018 and Codeforces Round #463 (Div. 1 + Div. 2, combined) A Palindromic Supersequence(代