isServer
编辑此页面import { isServer } from "solid-js/web";
const isServer: boolean;
这个变量用于指示代码是在服务器端还是浏览器端运行。 由于底层运行时将其导出为一个常量布尔值,这使得打包工具能够从各自的包中删除相应的代码及其使用的导入。
import { isServer } from "solid-js/web";
if (isServer) { // 这段代码永远不会出现在浏览器端的包中} else { // 这段代码不会在服务器端运行}