Skip to content

Select 组件 似乎不支持 Vitepress 这种ssr的场景 #112

@shenjunjian

Description

@shenjunjian

在一个vitepress项目中引用了Select组件,在运行时报错:

vitepress v1.6.3

  • building client + server bundles...
    ✓ building client + server bundles...
    /home/runner/work/icons/icons/node_modules/.pnpm/lu2@2024.9.2/node_modules/lu2/theme/edge/js/common/ui/Follow.js:20
    HTMLElement.prototype.follow = function (eleTarget, options) {
    ^

ReferenceError: HTMLElement is not defined
at Object. (/home/runner/work/icons/icons/node_modules/.pnpm/[email protected]/node_modules/lu2/theme/edge/js/common/ui/Follow.js:20:1)
at Module._compile (node:internal/modules/cjs/loader:1529:14)
at Module.extensions..js (node:internal/modules/cjs/loader:1613:10)
at Module.load (node:internal/modules/cjs/loader:1275:32)
at Module.load (node:internal/modules/cjs/loader:1096:12)
at cjsLoader (node:internal/modules/esm/translators:298:15)
at ModuleWrap. (node:internal/modules/esm/translators:240:7)
at ModuleJob.run (node:internal/modules/esm/module_job:263:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:540:24)
at async build (file:///home/runner/work/icons/icons/node_modules/.pnpm/[email protected]_patch_hash=tlnxzbihbonwbuvnbcvsp2zqhq
@algolia[email protected]
@types+no_nlwdeth6vfi2jtkor5c5he2wyu/node_modules/vitepress/dist/node/chunk-Zsoi3j4v.js:49587:24)

建议在javascript源码部分,能增加 isBrowser 的判断,避免在node环境下报错!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions