Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
SunKechang opened this issue Jan 22, 2021 · 0 comments
Open

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

SunKechang opened this issue Jan 22, 2021 · 0 comments

Comments

@SunKechang
Copy link

[扼要问题描述]

mpvue 版本号:

[[email protected]]

最小化复现代码:

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

<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

@SunKechang SunKechang changed the title computed属性未使用,getter方法却 computed属性未使用,getter方法却被调用 Jan 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant