Skip to content

vue 的局限 #180

@lovelmh13

Description

@lovelmh13

script 和 template 带来的问题

  1. 在一个组件文件里,视图和代码是分开的,如果在组件 export 之前写的变量,在组件销毁以后也会保存在内存里,而不是一起被销毁。如果写在 data 里,那没事儿。 因为销毁的是组件,而我们写的组件的文件,不全是组件,只有 export 导出的那些代码会被用到组件里。
    有点儿像是闭包,如果处理不好会有内存泄漏的问题
    vue 示例:
image 在 mpx 里这么写: image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions