
- let item = document.getElementsByTagName("h1")[0]
- item.textContent = "New Heading"

-
- <script src="https://unpkg.com/vue@next">script>
- <style>
- .mt-4 {
- margin:10px;
- }
- style>
-
- <div id="app">div>
-
- <script>
- const { h, createApp } = Vue;
- const Stack = {
- props: ['size'],
- render() {
- const slot = this.$slots.default ? this.$slots.default() : [];
- return h(
- "div",
- { class: "stack" },
- slot.map((child) => {
- return h("div", { class: `mt-${this.$props.size}` }, [
- child,
- ]);
- })
- );
- },
- };
-
- const App = {
- template: `
-
- hello
-
- hello
- hello
-
- hello
- hello
-
-
-
- `,
- components: {
- Stack,
- },
- };
- createApp(App).mount("#app");
- script>
hoistStatic 是否确实从渲染函数中提升,以便在每个渲染器上重用它
好处
避免重新创建对象,然后扔掉
在模式算法中,两个节点在严格平等的情况下,我们可以跳过它,因为知道它永远不会改变
通过补丁和数组能为运行时提供足够的信息,忽略哪些已经被编译器推断永远不会改变的props

每次被更新或被diff时,我们需要看下onClick,以确保它不会改变