跳至主要內容
萌萌哒草头将军

萌萌哒草头将军

千里之行,始于足下

RaETable
一款开箱即用的antd表格组件库
console-loader
自动清除其他开发者console的loader
🚀超详细解读vue3.2源码——组件渲染流程

欢迎关注我的公众号:萌萌哒草头将军

入口->全局初始化->生成 vnode->挂载

入口函数

export const createApp = (...args) => {
  // 1.创建实例
  const app = ensureRenderer().createApp(...args);

  // 2. 重写实例的 mount 方法
  const { mount } = app;
  app.mount = (containerOrSelector) => {
    const container = normalizeContainer(containerOrSelector);
    if (!container) return;

    const component = app._component;
    if (!isFunction(component) && !component.render && !component.template) {
      // __UNSAFE__
      // Reason: potential execution of JS expressions in in-DOM template.
      // The user must make sure the in-DOM template is trusted. If it's
      // rendered by the server, the template should not contain any user data.
      component.template = container.innerHTML;
      // 2.x compat check
      if (__COMPAT__ && __DEV__) {
        for (let i = 0; i < container.attributes.length; i++) {
          const attr = container.attributes[i];
          if (attr.name !== "v-cloak" && /^(v-|:|@)/.test(attr.name)) {
            compatUtils.warnDeprecation(
              DeprecationTypes.GLOBAL_MOUNT_CONTAINER,
              null
            );
            break;
          }
        }
      }
    }

    // clear content before mounting
    container.innerHTML = "";
    const proxy = mount(container, false, resolveRootNamespace(container));
    if (container instanceof Element) {
      container.removeAttribute("v-cloak");
      container.setAttribute("data-v-app", "");
    }
    return proxy;
  };

  return app;
};

萌萌哒草头将军大约 7 分钟前端Vue
🎉干货满满,React设计原理(四):藏在源码里的传呼机,Dispatch机制和事件系统🎉

文章同步更新在公众号:萌萌哒草头将军,欢迎关注

好久不见,该系列已经更新了三篇了,上文介绍了 React 是如何通过 Lane 模型判断更新任务的优先级的,视野聚焦于 Lane 模型的原理,今天我们详细看看 Lane 模型工作前发生了啥。

💡 相关阅读


萌萌哒草头将军大约 8 分钟前端JavaScriptReact
HTML实用小技巧🚀🚀

文章同步在公众号:萌萌哒草头将军,欢迎关注

💡Tip 1:告别 display: none

当你需要隐藏一个元素时,首先想到的可能是display: none,或者visibility: hidden,

现在有一个更简便的方式:直接在HTML元素使用hidden属性,它的值还可以是hidden="hidden"或者hidden="invalid value"


萌萌哒草头将军大约 2 分钟前端HTML
简简单单一个vite⚡⚡插件搞定用户的另类需求——自给自足的感觉真好

文章同步在公众号:萌萌哒草头将军,欢迎关注!

需求背景

前几天我们的客户对我们组的客户经理提了个需求,每次上线前端页面需要在HTML里给定版本信息,因为我们客户单位会定期爬取版本信息进行汇总展示在大屏。

版本信息要求如下:

  • 上线日期
  • 上线内容描述
  • 对应git提交ID
  • 对应项目的版本号

调研

我立马想到使用插件,前几天我已经将项目脚手架换成vite了,我找了一圈,发现了几个相似的需求,不过都是直接生成 meta 标签,跟我的需求不符


萌萌哒草头将军大约 4 分钟前端JavaScriptVite
2
3
4
mmdctjj.jpg
mmdctjj.jpg

大家好,我是萌萌哒草头将军,欢迎关注我。