chenhuiYj / chenhuiYj/note

vue小问题3

Open
#24 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
6
Forks
0
PR merge metrics
No merged PRs in 30d

Description

1.data 和 computed 的区别

核心的区别在于 data 中的属性并不会随赋值变量的改动而改动,而computed 会

<script>
    let outer_obj = {num: 30}
    let app = new Vue({
        el: "#app",
        data: {
            temp: outer_obj, // 这一句一定要加,必须在 data 对象上存在才能让 Vue 将它转换为响应式
            num1: outer_obj.num
        },
        computed: {
            c_num () {
                return outer_obj.num
            }
        }
    })
</script>

当改变 outer_obj.num 的值,c_num 会随之改变,而 num1 不会

2.methods 和 computed 的区别

1.computed 是基于它们的响应式依赖进行缓存的。只要 computed 依赖的那个数据不变,computed 就不会重新计算,而 methods 是只要页面有任何数据变化导致数据的更新,methods 就会重新计算

2.computed 不能带参数

3.Vue 实例在渲染的时候数据解析的顺序

Vue 实例在渲染的时候数据解析的顺序问题,结论是props->methods->data->computed->watch->created

image

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No file, test, or entry point is named. The body contains explanatory notes about Vue data, computed, methods, and initialization order rather than a defined change, so the intended documentation update must be clarified before starting.

Written by the indexing model from the issue text.

Assessment

Tech stack
html
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.