当前位置: 首页 > news >正文

佛山做网站优化成都设计公司装修

佛山做网站优化,成都设计公司装修,建站工具有哪些,彩票娱乐网站建设slot 插槽的实现实际上就是一种 延时渲染#xff0c;把父组件中编写的插槽内容保存到一个对象上#xff0c;并且把具体渲染 DOM 的代码用函数的方式封装#xff0c;然后在子组件渲染的时候#xff0c;根据插槽名在对象中找到对应的函数#xff0c;然后执行这些函数做真正的…slot 插槽的实现实际上就是一种 延时渲染把父组件中编写的插槽内容保存到一个对象上并且把具体渲染 DOM 的代码用函数的方式封装然后在子组件渲染的时候根据插槽名在对象中找到对应的函数然后执行这些函数做真正的渲染。 /*** 创建 vnode*/ function createVNode(type, props null, children null) {if (props) {// 处理 props 相关逻辑标准化 class 和 style}// 对 vnode 类型信息编码// 创建 vnode 对象const vnode {type,props,// 其他一些属性}// 标准化子节点把不同数据类型的 children 转成数组或者文本类型normalizeChildren(vnode, children)return vnode }/*** 标准化子节点以及获取 vnode 节点类型 shapeFlagshapeFlag 最终为 SLOTS_CHILDREN | STATEFUL_COMPONENT*/ function normalizeChildren(vnode, children) {let type 0const { shapeFlag } vnode// 没有子节点if (children null) {children null}// 子节点为数组else if (isArray(children)) {type 16 /* ARRAY_CHILDREN */}// 子节点为对象else if (typeof children object) {// 子节点为元素或 teleportif ((shapeFlag 1/* ELEMENT */ || shapeFlag 64 /* TELEPORT */) children.default) {normalizeChildren(vnode, children.default())return}// 子节点为 slotelse {type 32/* SLOTS_CHILDREN */const slotFlag children._if (!slotFlag !(InternalObjectKey in children)) {children._ctx currentRenderinglnstance}// 处理类型为 FORWARDED 的情况else if (slotFlag 3 /* FORWARDED */ currentRenderinglnstance) {// 动态插槽if (currentRenderingInstance.vnode.patchFlag 1024/* DYNAMIC_SLOTS */) {children._ 2/* DYNAMIC */vnode.patchFlag | 1024 /* DYNAMIC SLOTS */}// 静态插槽else {children._ 1/* STABLE */}}}}// 子节点为函数else if (isFunction(children)) {children { default: children, _ctx: currentRenderinglnstance }type 32/* SLOTS_CHILDREN */}// 其他子节点else {children String(children)// teleport 类型if (shapeFlag 64/* TELEPORT */) {type 16/* ARRAY_CHILDREN */children [createTextVNode(children)]}// 文本类型else {type 8/* TEXT_CHILDREN */}}vnode.children childrenvnode.shapeFlag | type }/*** 初始化 Slots*/ const initSlots (instance, children) {if (instance.vnode.shapeFlag 32/* SLOTS_CHILDREN */) {const type children._if (type) {instance.slots childrendef(children, _, type)} else {normalizeObjectSlots(children, (instance.slots {}))}} else {instance.slots {}if (children) {normalizeVNodeSlots(instance, children)}}def(instance.slots, InternalObjectKey, 1) }/*** 渲染 slot DOM* param {Object} slots - 插槽对象 instance.slots* param {string} name - 插槽名*/ function renderSlot(slots, name, props {}, fallback) {// 根据 name 获取对应插槽函数let slot slots[name]// 通过 createBlock 创建 vnode 节点类型为 Fragmentchildren 是执行 slot 插槽函数的返回值return (openBlock(), createBlock(Fragment, { key: props.key }, slot ? slot(props) : fallback ? fallback() : [], slots._ 1/* STABLE */ ? 64/* STABLE_FRAGMENT */ : -2/* BAIL */)); }/*** 保证子组件中渲染具体插槽内容保证它的数据作用域也是父组件*/ function withCtx(fn, ctx currentRenderinglnstance) {if (!ctx) return fnreturn function renderFnWithContext() {// 保存当前渲染的组件实例 ownerconst owner currentRenderingInstance// 把 ctx 设置为当前渲染的实例setCurrentRenderinglnstance(ctx)// 执行 fnconst res fn.apply(null, arguments)// 把 ctx 设置为当前渲染的实例setCurrentRenderingInstance(owner)return res} }/*** 处理 Fragment*/ const processFragment (nl, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized) {const fragmentStartAnchor (n2.el n1 ? nl.el : hostCreateText())const fragmentEndAnchor (n2.anchor n1 ? nl.anchor : hostCreateText())let { patchFlag } n2if (patchFlag 0) {optimized true}// 插入节点if (n1 null) {// 先在前后插入两个空文本节点hostInsert(fragmentStartAnchor, container, anchor)hostInsert(fragmentEndAnchor, container, anchor)// 再挂载子节点mountChildren(n2.children, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, optimized)}//更新节点else { } }
http://www.sczhlp.com/news/173610/

相关文章:

  • html5企业网站网络系统建设与运维高级
  • 手机网站建设wap重新做系统后怎么没有wordpress
  • 动态图表网站个体户公司名称怎么取
  • 公司网站未备案吗邯郸网络营销平台建设
  • 徐州睢宁建设网站一键优化ppt
  • 房产中介网站开发公众号怎么开通留言
  • 蔺市网站建设wordpress 改邮箱
  • 上海兴业建设有限公司网站建设网站项目概述
  • 推荐网站建设的书中山那些网站公司
  • 上海市网站seo公司pageadmin的最新版本
  • 济南市住建局官方网站十佳深圳网站设计
  • 自己可以建立网站吗如何申请公众号
  • 网站源码下载软件深圳教育科技网站建设
  • 网站开发应注意什么如何注册一个网站
  • 网站建设要哪些seo搜索引擎营销推广方案
  • 网站建设标准流程及外包注意事项logo免费一键生成
  • 微网站开发程序超实用网站
  • 大连网站网页设计公司wordpress 文字底色
  • 第二次课动手动脑合集
  • centos8的防火墙管理
  • 网站建设教程 乐视网将wordpress安装到哪个数据库?
  • wordpress 游戏网页成都关键词优化技术
  • 不合理的网站互联网网站建设价格
  • 哈尔滨网站开发企业网站建设图片属性设置
  • 自己做网站要不要钱企查查企业信用查询
  • 宛城区微网站开发wordpress安装博客步骤
  • 好网站的标准新建门户网站的建设自查
  • 广州网站建设好评公司网站标题导航栏
  • 金华模板建站定制网站医美三方网站怎么做
  • 棋牌游戏网站模板下载安装哪里有给网站做360