您的位置 首页 golang

Vue基础入门,第14节 属性的计算computed

1、需要的属性不存在,需要通过已有的属性来计算得到

Vue基础入门,第14节 属性的计算computed

2、原理是借助了object.defineproperty方法提供的getter和setter

Vue基础入门,第14节 属性的计算computed

3、get函数什么时候执行:

(1)首次读取时候执行1次

(2)当以来的数据发生改变的时候,会再次被调用

Vue基础入门,第14节 属性的计算computed

4、与methods实现相比,内部有缓存机制,效率更高,调试更方便

5、备注:

(1)计算属性后最终会出现在vm上,允许直接读取

Vue基础入门,第14节 属性的计算computed

(2)如果计算属性要被修改,必须写set函数来响应修改,并且set函数中要引起计算式以来的数据发生

Vue基础入门,第14节 属性的计算computed

 <!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>demo1.html</title>
    <link rel="stylesheet" href="static/css/bootstrap.css">
    <!-- 导入vue文件 -->
    <script src="static/js/vue.js"></script>
    <script src="static/js/vue-router.js"></script>
</head>
<body class="container">
<div id="app">
    <!--
    1、需要的属性不存在,需要通过已有的属性来计算得到
    2、原理是借助了object.defineproperty方法提供的getter和setter
    3、get函数什么时候执行:
        (1)首次读取时候执行1次
        (2)当以来的数据发生改变的时候,会再次被调用
    4、好处:与methods实现相比,内部有缓存机制,效率更高,调试更方便
    5、备注:
        (1)计算属性后最终会出现在vm上,允许直接读取
        (2)如果计算属性要被修改,必须写set函数来响应修改,并且set函数中要引起计算式以来的数据发生
    -->
    <p><a class="btn btn-block btn-primary" href="./demo1.html">计算属性示例</a></p>
    <pre v-html="getFullName()"></pre>
    <div class="form-group">
        <label>username</label>
        <input type="text" class="form-control"  v-model="Username">
    </div>
    <div class="form-group">
        <label>say</label>
        <input type="text" class="form-control" v-model="Say">
    </div>
    <pre v-text="UserSay"></pre>
</div>
<script>
    Vue.config.productionTip = false
    const vm = new Vue({
        el: "#app",
        data: {
            Username: "Goer",
            Say: "php是世界上最好的语言",
        },
        methods: {
            getFullName: function (e) {
                return "张无忌"
            }
        },
        computed: {
            UserSay: {
                get() {
                    console.log("get被调用了!")
                    return this.Username + " 说: " + this.Say
                },
                set(value) {
                    console.log("set被调用了,值是:", value)
                }
            }
        }
    })
</script>
</body>
</html>  

文章来源:智云一二三科技

文章标题:Vue基础入门,第14节 属性的计算computed

文章地址:https://www.zhihuclub.com/97326.shtml

关于作者: 智云科技

热门文章

评论已关闭

30条评论

  1. Invasive ER positive breast cancer was non significantly reduced by 24 with anastrozole when compared to tamoxifen 44 vs

  2. Brand BioQuest Pharma When used alone, HGH will provide results but you may not get the full effect without stacking this with powerful anabolic steroids

  3. This oilMontelukast acid in ethanol, by equimolar amounts of sodium hydroxide solution and converted to montelukast sodium There are rare reports of hepatocellular carcinoma in patients receiving long term therapy with androgens in high doses

  4. Withdrawal symptoms can include seizures, psychosis losing touch with reality, hallucinations, mood changes, tremors, abdominal pain, and muscle cramps

  5. Administration of rPEDF prevents c Myc elevation, suggesting a decreased risk of malignant development

  6. The best candidates for neoadjuvant chemotherapy are ER negative or HER2 positive expressing tumors in which pCR rates are generally above 20 and predict long term survival

  7. f Metabolic dependency and capacity of wt MCF7, MCF7 LTED wt, and MCF7 LTED Y537C on glutamine, fatty acid, and glucose using a Seahorse XFe96 analyzer n 4 technical replicates

  8. Dianabol production had meteoric history, exploding for quite some time, then quickly dropping out of sight

  9. Therefore, utilizing a selection cassette to select for the successfully targeted clones can reduce the number of negative colonies Fig The study protocol was approved by the University of South Florida Institutional Review Board

  10. From this experiment, however, we could not conclude whether re expression of E177R prevented tumor formation, limited cancer progression or induced regression of established tumors

  11. Male Sprague Dawley rats weighing 250 300 g were used in this study, with the exception of the furosemide experiments, which were conducted on male Holtzman rats

  12. Please note that some features of the Service may be provided under additional and separate legal agreements

  13. The time limit is one hour, I do not know, what do you two think Bai Guanshi said lightly

  14. Serious Use Alternative 1 saquinavir will increase the level or effect of lemborexant by affecting hepatic intestinal enzyme CYP3A4 metabolism

  15. They will also teach you how and when to drain the fluid Bakry S, Merhi ZO, Scalise TJ, Mahmoud MS, Fadiel A, Naftolin F

  16. He always thinks outside the box An important point is that many of the above clinical studies using noncytotoxic agents predate the widespread use of objective response criteria such as the RECIST criteria

  17. This was undertaken separately for each of the 1000 sample data sets deep vein thrombosis

  18. Spironolactone is a potassium and magnesium sparing diuretic that antagonizes the effects of aldosterone by binding to mineralocorticoid receptors in the distal collecting duct There are numerous handicapping angles in horse racing, all of which can lead to profits when identified and applied at the right time

  19. HFD fed mice showed higher insulin levels than chow fed mice as expected, but there were no differences observed between treatment groups under HFD conditions Fig

  20. in the case of EGF, EGFR expressing tumor cells Dr prescribed 200 mg oral progesterone 1 time a day

  21. Consulting or Advisory Role Bayer, Janssen Oncology, Amgen, Pfizer, Eli Lilly, Novartis, Astellas Pharma

网站地图