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

个别网站网速慢怎么做企业推广网站

个别网站网速慢怎么做,企业推广网站,网站运营与公司简介,怎样做理财投资网站1.依赖关系 runtime-dom 依赖于runtime-core,runtime-core 依赖于reactivity和sharedruntime-core提供跨平台的渲染方法createRenderer,用户可以自己传递节点渲染的渲染方法renderOptions,本身不关心用户使用什么APIruntime-dom提供了为浏览器而生的渲染…

1.依赖关系

  • runtime-dom 依赖于runtime-core,runtime-core 依赖于reactivityshared
  • runtime-core提供跨平台的渲染方法createRenderer,用户可以自己传递节点渲染的渲染方法renderOptions,本身不关心用户使用什么API
  • runtime-dom提供了为浏览器而生的渲染方法renderrender方法调用runtime-corecreateRenderer方法传递的renderOptions runtime-dom封装好的一系列关于渲染浏览器dom节点的操作
const renderOptions = Object.assign({ patchProp }, nodeOps);
export const render = (vnode,container)=>{return createRenderer(renderOptions).render(vnode,container)
}

2.init

2.1 package init

runtime-core/package.json

{"name": "@vue/runtime-core","version": "1.0.0","main": "index.js","module": "dist/runtime-core.esm-bundler.js","unpkg": "dist/runtime-core.global.js","buildOptions": {"name": "RuntimeCore","formats": ["esm-bundler","esm-browser","cjs","global"]},"dependencies": {"@vue/reactivity": "^3.4.30","@vue/shared": "*"}
}

2.2 调整runtime-dom/index依赖


import { nodeOps } from "./nodeOps";
import patchProp from "./patchProp";
import {createRenderer} from '@vue/runtime-core'const renderOptions = Object.assign({ patchProp }, nodeOps);
export { renderOptions };// 如果我们采用的是runtime-dom中的render方法,我们不需要传递renderOptions,因为会把runtime-dom 这一层的dom处理方法传递进去,主要为浏览器而生的
// 如果我们用的是runtime-core 中的createRenderer,需要用户自己传递renderOptions   并不关心采用什么api// runtime-dom 是内置的dom api 会去调用createRenderer,传入渲染选项,返回的渲染器有一个render方法
// 采用dom api 进行渲染
export const render = (vnode,container)=>{return createRenderer(renderOptions).render(vnode,container)
}export  * from "@vue/runtime-core"

3.实现

3.1 init

createRenderer接受一个参数dom渲染相关配置,提供一个render方法,参数为虚拟节点和真实的dom元素

export function createRenderer(renderOptions) {const {insert: hostInsert,remove: hostRemove,patchProp: hostPatchProp,createElement: hostCreateElement,createText: hostCreateText,setText: hostSetText,setElementText: hostSetElementText,parentNode: hostParentNode,nextSibling: hostNextSibling,} = renderOptions;const render = (vnode, container) => {// 将虚拟节点变成真实节点进行渲染 };return {render,};
}

3.2 render实现

const mountElement = (vnode, container) => {console.log(vnode);const { type, children, props } = vnode;let el = hostCreateElement(type);if (props) {for (let key in props) {hostPatchProp(el, key, null, props[key]);}}hostSetElementText(el, children);hostInsert(el, container);};const patch = (n1, n2, container) => {if (n1 == n2) {return;}if (n1 == null) {mountElement(n2, container);}};// core 中不关心如何渲染const render = (vnode, container) => {// 将虚拟节点变成真实节点进行渲染patch(container._vnode || null, vnode, container);container._vnode = vnode;};

vnode如图:
在这里插入图片描述

const ele1 = h("h1",{ style: { color: "red" }},"hello world");const ele2 = h("h1",{ style: { color: "green" } },"hello world");render(ele1, document.getElementById("app"));setTimeout(()=>{render(ele2, document.getElementById("app"));},3000)

此时可以实现基础渲染,由于我们知道节点children是文本,可以直接使用文本进行渲染,那如果dom里面又嵌套一个dom呢?

3.3 shapeFlag

为了能够判断子节点的类型,定义一个枚举

export const enum ShapeFlags { // vue3提供的形状标识ELEMENT = 1,FUNCTIONAL_COMPONENT = 1 << 1,STATEFUL_COMPONENT = 1 << 2,TEXT_CHILDREN = 1 << 3,ARRAY_CHILDREN = 1 << 4,SLOTS_CHILDREN = 1 << 5,TELEPORT = 1 << 6,SUSPENSE = 1 << 7,COMPONENT_SHOULD_KEEP_ALIVE = 1 << 8,COMPONENT_KEPT_ALIVE = 1 << 9,COMPONENT = ShapeFlags.STATEFUL_COMPONENT | ShapeFlags.FUNCTIONAL_COMPONENT
}

比如const ele1 = h("h1", { style: { color: "red" } }, "hello world");是节点和文本的组合,节点为1,文本为8,采用或运算,得出节点类型数据9,可以看到上图中节点的shapeFlag为9,采用&运算得出节点具体类型 8&9=1000&1001=1000>0 则证明包含这个类型

const mountChildren = (children, container) => {for(let i=0;i<children.length;i++) {// 数组可能为字符串而不是节点patch(null, children[i], container)}};const { type, children, props, shapeFlag } = vnode;if (shapeFlag & ShapeFlags.TEXT_CHILDREN) {hostSetElementText(el, children);} else if (shapeFlag & ShapeFlags.ARRAY_CHILDREN) {mountChildren(children, el);}

此处判断了TEXT_CHILDREN是文本,ARRAY_CHILDREN是数组

const ele3 = h("h1", { style: { color: "red" } }, [h("p", "hello"),h("p", "world"),]);

可以正确渲染

http://www.yidumall.com/news/99803.html

相关文章:

  • 网站实时推送怎么做滁州网站seo
  • 淘宝刷单网站开发疫情防控数据
  • 帮客户做ppt什么的在哪个网站百度平台商家
  • 深圳网站建设 设计卓越想做电商怎么入手
  • 中山外贸网站建设优化网站搜索排名
  • 怎么做网站banner在线资源链接
  • 建筑网站带图解谷歌seo网站推广怎么做
  • 如何在谷歌上做网站一个免费的网站
  • 厦门微信网站建seo外包收费
  • wordpress 李贤威seo推广排名公司
  • 小尾巴 wordpress上海外包seo
  • 三星做号网站商丘网络推广公司
  • 网站开发和移动开发泸州网站seo
  • 如何构建个人网站谷歌广告投放教程
  • 平邑网站定制宁波seo网络推广
  • 网站的后台怎么做电话营销技巧和营销方法
  • 安化网站建设公司网络营销策划书
  • 做什么网站吸引人百度普通下载
  • 青岛网站建设华夏网络营销公司有哪些
  • 合肥定制网站建设seo快速优化文章排名
  • 大理旅游网站建设抖音seo搜索优化
  • 网站优化入门怎么知道网站有没有被收录
  • 网站开发怎么做电子商务网站建设规划方案
  • wordpress 数据图片存在哪seo网站有优化培训吗
  • 如何用frontpage2003做网站百度推广登录网站
  • 网站管理模板seo刷排名软件
  • 即时通讯网站开发源码b站推广费用一般多少
  • 企业网站有哪些功能?品牌营销理论有哪些
  • 网站推广站点建设与策划神马seo服务
  • 深圳网站建设合同sem工作内容