Coder Social home page Coder Social logo

Vue 模板编译原理 about blog HOT 16 OPEN

berwin avatar berwin commented on May 13, 2024 58
Vue 模板编译原理

from blog.

Comments (16)

berwin avatar berwin commented on May 13, 2024 3

@li-changyu 可以看一下Vue作者在知乎的回答 https://www.zhihu.com/question/49929356/answer/118534768

from blog.

berwin avatar berwin commented on May 13, 2024 1

@pomelovico 您好~ 不是的,模板编译只是会把模板编译成渲染函数,只有在渲染函数被执行的时候才会对数据进行访问,而渲染函数是在watche实例中执行的,所以渲染函数中所使用到的所有数据,都会被同一个Watcher监听,当这些状态发生变化时,会通知这个Watcher,这个Watcher会触发VirtualDOM对组件进行渲染。

一个组件的模板会被编译成一个渲染函数。每个组件有一个Watcher用来监听模板中所使用到的数据、当这些数据发生变化时,通过VirtualDOM进行更新组件的视图

from blog.

codezyc avatar codezyc commented on May 13, 2024

很详细,赞

from blog.

BetaSu avatar BetaSu commented on May 13, 2024

非常棒, 感谢分享!

from blog.

fighthorse avatar fighthorse commented on May 13, 2024

非常不错

from blog.

pomelovico avatar pomelovico commented on May 13, 2024

博主你好,请问在模板编译的阶段,是不是就会对每个组件所使用的data或者computed值进行访问,从而创建新的Watcher进行订阅,然后对应的属性的dep就会收集这些watcher,从而实现更新的?

from blog.

AlvinYuXT avatar AlvinYuXT commented on May 13, 2024

请问一下,为什么单个文本节点如果标记了 消耗会更大

from blog.

berwin avatar berwin commented on May 13, 2024

@AlvinYuXT 我也不是很清楚为什么,嘿嘿嘿、如果有人知道希望在评论中通知我一下,跪谢~

from blog.

AlvinYuXT avatar AlvinYuXT commented on May 13, 2024

@berwin 看了一下,可能是因为在renderStatic的时候 需要clone一遍VNode。

from blog.

li-changyu avatar li-changyu commented on May 13, 2024

请教一下为什么生成render function的时候用到了 with(this) {
... } 这种写法,使用with语句不会对性能有影响吗?

from blog.

zoloadang avatar zoloadang commented on May 13, 2024

👍 💯 好文章,理解起来还是挺有帮助的,收藏!

from blog.

liang520 avatar liang520 commented on May 13, 2024

这个with在线构建的方案使用的真的是很精妙

from blog.

LonHon avatar LonHon commented on May 13, 2024

好文,很有帮助.

因为在 HTML 中有一种 自闭和标签,比如 input。

改为自闭合标签好些? 😆

from blog.

berwin avatar berwin commented on May 13, 2024

@LonHon 哈哈哈,错别字,已改。可以关注下我的新书,书里讲的比文章要详细很多。

from blog.

SkyJinXX avatar SkyJinXX commented on May 13, 2024

精辟!就是模板解析器那里专门去看了博主的另一篇文章才懂

from blog.

L-LingRen avatar L-LingRen commented on May 13, 2024

for 嵌套作用域是怎么处理的?这模板原理没看出来。

from blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.