Skip to content

computed属性未使用,getter方法却被调用 #1828

@bloomingtree

Description

@bloomingtree

[扼要问题描述]

mpvue 版本号:

[mpvue@2.0.0]

最小化复现代码:

[建议提供最小化可运行的代码:附件或文本代码]

<template>
    <div id="demo">
            <input type="text" v-model="firstName">
         <input type="text" v-model="lastName">
    </div>
</template>
<script>
export default{
    data(){
        return {
            firstName: "Here is First Name",lastName: "Here is Last Name"
        }
    },
    computed: {
        fullName: function () {
        console.log('computed getter...')
        return this.firstName + ' ' + this.lastName
        }
    }
}
</script>

问题复现步骤:

观察到的表现:
在dom区没有调用computed中fullName属性,而
改变其依赖的响应式变量firstName或lastName在console.log()中可以观察到computed的属性方法被调用

截图或动态图:
xxx 00_00_00-00_00_30

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions