vue#render TypeScript Examples

The following examples show how to use vue#render. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: custom-tooltip.ts    From S2 with MIT License 6 votes vote down vote up
renderContent() {
    // 配置级 s2.options.tooltip.content = ''
    const { tooltip } = this.spreadsheet.options;
    // 方法级 s2.showTooltip({ content: '' })
    const showOptions = this.options;
    const cell = this.spreadsheet.getCell(
      showOptions.event?.target as EventTarget,
    );
    // 优先级: 方法级 > 配置级, 兼容 content 为空字符串的场景
    const content = showOptions.content ?? tooltip?.content;

    const tooltipProps: TooltipRenderProps<TooltipShowOptions['content']> = {
      ...showOptions,
      cell,
      content,
    };

    const tooltipVNode = createVNode(
      TooltipComponent,
      tooltipProps as VNodeProps,
    );

    // render(null) 确保每一次的 tooltip 内容是最新的
    render(null, this.container);
    render(tooltipVNode, this.container);
  }
Example #2
Source File: vue-template.tsx    From vue3-datagrid with MIT License 6 votes vote down vote up
vueTemplateConstructor =
    (vueConstructor: DefineComponent, e: HTMLElement|null, p: Record<string, any>) => {
        if (!e) {
            return null;
        }
        let el: VueElement|undefined;
        if (e?.childNodes.length) {
            el = e.childNodes[0] as VueElement;
        }
        
        if (!el) {
            // create dom element wrapper for vue instance
            el = document.createElement('span');
            e.appendChild(el);
        }
        // check, probably vue instance already inited
        let vueInstance = el._vnode;
        // if exists, return
        if (vueInstance) {
            // if vue inited just update it's properties
            for (const k in p) {
                vueInstance.component.props[k] = p[k];
            }
        } else {
            const vNode = createVNode(vueConstructor, p);
            render(vNode, el);
        }
        return vueInstance;
    }
Example #3
Source File: custom-tooltip.ts    From S2 with MIT License 5 votes vote down vote up
destroy() {
    super.destroy();
    if (this.container) {
      render(null, this.container);
    }
  }
Example #4
Source File: index.ts    From gitmars with GNU General Public License v3.0 5 votes vote down vote up
show() {
        render(this.instance, this.$el)
    }
Example #5
Source File: index.ts    From gitmars with GNU General Public License v3.0 5 votes vote down vote up
hide() {
        render(null, this.$el)
        document.body.removeChild(this.$el)
        this.$el = null
        this.instance = null
        delete this.$el
        delete this.instance
    }