我在 Svelte 中制作了一个应用程序,现在我想将其移植到 SvelteKit。我的应用程序使用window
和document
对象,但这些在 SSR 中不可用。首先,它抛出了ReferenceError: window is not defined
,但我通过检查应用程序是否在浏览器中运行来解决这个问题。但正因为如此,我的应用程序无法运行。
我正在使用 Angular 14 和 Webpack 版本:^5.58.1
。
下面是配置:
webpack.config.js
const webpackPlugin = require('@ngtools/webpack').AngularWebpackPlugin;
module.exports = {
mode: 'development',
devtool: "source-map",
entry: {
main: "./js/main.js",
mainDrawer: "./js/divdrawer/main.ts",
polyfills: "./js/divdrawer/polyfills.ts",
entry: "./js/entry.js",
thirdpartylibs: "./js/thirdpartylibs.js"
},
output: {
path: path.join(__dirname, "build/"),
filename: "[name]bundle.js"
},
module: {
rules: [
{
parser: {
system: true,
}
}
test : /\.(tsx|ts)$/,
use: [
{
loader: '@ngtools/webpack',
options: {
configFile: path.resolve('./js/tsconfig.json')
},
},
]
},
},
plugins: [
new webpackPlugin({
tsconfig: './js/tsconfig.json',
}),
new webpack.ContextReplacementPlugin(
/\@angular(\\|\/)core(\\|\/)esm5/, …
Run Code Online (Sandbox Code Playgroud) javascript angular-webpack webpack-5 angular14 angular14upgrade
当我在 Python3 和 Mac OS 上启动 Flask 应用程序时,遇到此错误:
OSError:无法加载库“gobject-2.0-0”:dlopen(gobject-2.0-0, 2):找不到图像。此外,ctypes.util.find_library() 无法找到名为“gobject-2.0-0”的库
我weasyprint
在我的项目中使用它导致了这个问题。
我尝试安装glib
,它已安装在我的系统中。
在打字稿中,我们有Partial 类型,所以我们可以这样做:
interface Foo {
x:number
y:number
}
const foo:Partial<Foo> = {x: 1}
Run Code Online (Sandbox Code Playgroud)
(通过这个我们可以使接口的所有属性都是可选的)
在 Python 中,我们可以使用 来做到这一点total=False
,如下所示:
from typing_extensions import TypedDict
class Foo(TypedDict, total=False):
x:int
y:int
foo:Foo = {'x':1}
Run Code Online (Sandbox Code Playgroud)
但这种方法不太好,因为这意味着 allFoo
必须将所有属性尽可能为 None,并且我们需要进行大量类型转换。在 python 中,是否有一种方法可以声明 TypedDict,然后将其某些实现作为该类型的子集,如下所示:
from typing_extensions import TypedDict
class Foo(TypedDict):
x: int
y: int
foo:Partial[Foo] = {'x': 1}
Run Code Online (Sandbox Code Playgroud) 尝试使用 apt 包管理器更新 GitHub CLI 失败并出现以下错误:
Failed to fetch https://cli.github.com/packages/dists/stable/InRelease: The following signatures couldn't be verified because the public key is not available: EXPKEYSIG C99B11DEB97541F0
GPG error: The following signatures were invalid: EXPKEYSIG C99B11DEB97541F0
Run Code Online (Sandbox Code Playgroud) 当我做:
>>> import os
>>> os.uname()
Run Code Online (Sandbox Code Playgroud)
我收到一个属性错误,如下所示:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
os.uname()
AttributeError: module 'os' has no attribute 'uname'
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题,因为我的 python 坏了或者是其他什么原因,因为在文档中。
我是新手,首先,我实际上不知道我需要什么样的结构。
我需要构建多个应用程序,但其中一些依赖于相同的组件。
到目前为止效果很好,但我认为混合了一些东西
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
<script type="module" crossorigin src="/assets/modules/modules\\VPlayerList\\index-74e8dd8e.js"></script>
<link rel="modulepreload" crossorigin href="/assets/js/main-a0df4ea4.js">
<link rel="stylesheet" href="/assets/main.44382b18.css">
</head>
<body>
<div id="app"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
参考资料错误,我错过了什么?
忘记附上vite配置:
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import path, { resolve } from 'path'
import glob from 'glob';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue(), …
Run Code Online (Sandbox Code Playgroud) 我有这个简单的你好世界程序:
#include <stdio.h>
int main() {
printf("Hello, world!\n");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我像平常一样用 LLVM Clang(v15.0.1,从 Homebrew 构建,所以不是 Apple 的版本)编译了这个程序,然后运行并计时了输出。令我惊讶的是,程序第一次运行的时间比第二次长了近 10 倍,但接下来的 3 次执行运行速度要快得多。
#include <stdio.h>
int main() {
printf("Hello, world!\n");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我在 Intel Core i5 mac 上运行此程序,运行 macOS Big Sur v11.6.8。shell 是bash
随 macOS 一起提供的。
我的代码中没有任何内容涉及时间,而且我认为没有任何内容可以缓存,所以我不确定为什么第一次执行运行得这么慢。我怀疑操作系统可能正在进行某种优化,但我不知道是什么/如何进行。造成运行时间如此巨大差异的原因是什么?
我正在尝试创建虚拟环境,但它显示此错误
PermissionError: Operation not permitted: '/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/bin/python3.8' -> '/storage/emulated/0/my/bin/python'
Run Code Online (Sandbox Code Playgroud) python ×3
javascript ×2
angular14 ×1
benchmarking ×1
c ×1
clang ×1
flask ×1
git ×1
github-cli ×1
glib ×1
html ×1
linux ×1
macos ×1
partial ×1
python-3.x ×1
repository ×1
svelte ×1
sveltekit ×1
type-hinting ×1
typeddict ×1
virtualenv ×1
vite ×1
weasyprint ×1
webpack-5 ×1
x86 ×1
xcode ×1
xcode14 ×1