我想声明两条 Angular 路线:
/items?id=SOME_ITEM_ID)/items)由于以下不起作用,我想知道如何定义我的路线以满足我的需求?
export const routes: Routes = [
{ path: 'items?id=someItemId', component: ItemComponent },
{ path: 'items', component: AllItemsComponent },
];
Run Code Online (Sandbox Code Playgroud) 我的 NgRx 实现有一个智能组件测试,如下所示:
describe( 'Component', () => {
let store: MockStore<State>;
beforeEach( async( () => {
TestBed.configureTestingModule( {
/* ... */
providers: [
provideMockStore( { initialState: fromReducer.initialState } )
]
} ).compileComponents();
store = TestBed.get<Store<State>>( Store );
} ) );
it( 'should load items in #ngOnInit', () => {
store.setState( {
item: {
...fromReducer.initialState,
entities: { [item.id]: item },
},
otherFeature: null,
otherFeature: null,
otherFeature: null
} );
component.items$.subscribe( items =>
store.select( ItemStoreSelectors.selectItems ).subscribe( fromStore => expect( items ).toEqual( fromStore …Run Code Online (Sandbox Code Playgroud) 我想编译一些 Typescript 文件并从编译的 Javascript 文件创建一个 Node.js 图像。当我只有一个带有此BUILD文件的Typescript 文件时,它工作正常:
load("@io_bazel_rules_docker//nodejs:image.bzl", "nodejs_image")
load("@npm_bazel_typescript//:index.bzl", "ts_library")
ts_library(
name = "compile",
srcs = ["src/index.ts"],
)
filegroup(
name = "files",
srcs = ["compile"],
output_group = "es5_sources",
)
nodejs_image(
name = "server",
entry_point = "files",
)
Run Code Online (Sandbox Code Playgroud)
但是一旦我像这样引入多个Typescript 文件:
load("@io_bazel_rules_docker//nodejs:image.bzl", "nodejs_image")
load("@npm_bazel_typescript//:index.bzl", "ts_library")
ts_library(
name = "compile",
srcs = ["src/index.ts", "src/util.ts"],
)
filegroup(
name = "files",
srcs = ["compile"],
output_group = "es5_sources",
)
nodejs_image(
name = "server",
data = ["files"],
entry_point = …Run Code Online (Sandbox Code Playgroud) 我正在使用Stripe Elements信用卡结帐。问题是,我不能(或者我根本不知道如何)CSS variables在这个Stripe Element. CSS variables当用户更改主题时,我需要使用以更改颜色。这是我目前的实现:
变量定义(我使用的是 SASS)
.theme1
--color-1: red
--color-2: pink
// ...
.theme2
--color-1: blue
--color-2: lilec
// ...
.theme3
--color-1: orange
--color-2: yellow
// ...
// ...
Run Code Online (Sandbox Code Playgroud)
的CSS variables是一类的范围内,即投入到在限定的body当前选择取决于哪个主题。
HTML(我使用的是 Angular 6)
<div #stripe></div>
Run Code Online (Sandbox Code Playgroud)
打字稿
@ViewChild('stripe') el: ElementRef;
card: any;
cardHandler = this.onChange.bind(this);
async onSubmit() { /* ... */ }
setupStripe(): void {
this.card = stripeElements.create('card', {
iconStyle: 'solid',
style: {
base: { …Run Code Online (Sandbox Code Playgroud) 我有一条快速路线,可以上传文件,并通过formData.
假设文件是一个.rar文件,我的目标是提取此存档或其子文件夹中的所有文件名。
这是我的快递路线目前的样子:
module.exports = async (req, res) => {
try {
const busboy = new Busboy({ headers: req.headers })
busboy.on('finish', async () => {
const fileData = req.files.file
console.log(fileData)
// upload file
// send back response
})
req.pipe(busboy)
} catch (err) { return response.error(req, res, err, 'uploadProductFile_unexpected') }
}
Run Code Online (Sandbox Code Playgroud)
这是console.log(fileData)外观:
{
data:
<Buffer 52 61 72 21 1a 07 01 00 56 0c 22 93 0c 01 05 08 00 07 01 01 …Run Code Online (Sandbox Code Playgroud) 运行时sudo npm i sharp --save出现以下错误:
> sharp@0.21.3 install /home/server/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
info sharp Using cached /home/ronny/.npm/_libvips/libvips-8.7.0-linux-x64.tar.gz
ERR! sharp EACCES: permission denied, mkdir '/home/server/node_modules/sharp/vendor'
info sharp Attempting to build from source via node-gyp but this may fail due to the above error
info sharp Please see https://sharp.pixelplumbing.com/page/install for required dependencies
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/server/node_modules/sharp/build'
gyp ERR! System Linux …Run Code Online (Sandbox Code Playgroud) 我想使用 3D 画布截取网页的屏幕截图,如下所示:
import {createServer} from 'http'
import puppeteer from 'puppeteer'
const url = "https://webglfundamentals.org/webgl/webgl-load-obj-w-extents.html";
async function main() {
const browser = await puppeteer.launch({
args: [
"--no-sandbox",
"--use-gl=swiftshader",
"--enable-webgl",
],
headless: true,
dumpio: true,
defaultViewport: { width: 400, height: 300 },
});
const page = await browser.newPage();
await page.goto(url);
await page.waitForNetworkIdle();
await page.waitForSelector("#canvas");
const screenshot = await page.screenshot();
console.log(screenshot);
Run Code Online (Sandbox Code Playgroud)
在我的 Ubuntu 机器上本地运行代码工作正常,生成此图像:

在 Docker 容器( Ubuntu + Node.js + Chrome )中运行代码不起作用。它会截取屏幕截图,但 3D 画布不会渲染。
[end of stack trace]
[0927/180308.980024:ERROR:gpu_process_host.cc(961)] GPU process …Run Code Online (Sandbox Code Playgroud) 目前,我正在使用a和href。但我不希望客户端能够获取 URL。
<a href="URL">Download</a>
Run Code Online (Sandbox Code Playgroud)
因此,我只是想问如何通过 Javascript 启动文件下载。(假设我有可用的网址)
我需要一个采用 3 种输入颜色并产生噪声的着色器,如下所示。借助“噪声纹理”和“颜色渐变”节点,在 Blender 中很容易实现。
我找到了这个 gist,这可能会解决我的问题。但我无法配置颜色。而且噪音看起来比 Blender 中的结果“更锐利”。
我需要为此编写自己的着色器还是有更简单的方法来使用 ThreeJS 实现这种效果?
try {
await function1()
await function2()
await function3().catch(err => { /*...*/ })
} catch (err) { /*...*/ }
Run Code Online (Sandbox Code Playgroud)
我的问题是,即使异常已被" catch捕获" ,块是否捕获了由此发出function3的异常.catch(err => ...)?
如果catch块捕获异常function3,我的问题是如何防止这种行为?
我的目标基本上是捕获这些函数的特定异常,并将catch块用于每个未处理的异常.
如何使用 Node.js 和 Bazel 设置 gRPC 的GRPC 健康检查?
node.js ×5
javascript ×4
typescript ×4
angular ×3
bazel ×2
html ×2
url ×2
angular-test ×1
angular7 ×1
archive ×1
blender ×1
css ×1
docker ×1
download ×1
file ×1
glsl ×1
grpc ×1
kubernetes ×1
ngrx ×1
ngrx-store ×1
npm ×1
puppeteer ×1
rar ×1
sass ×1
shader ×1
sharp ×1
three.js ×1
try-catch ×1
webgl ×1
winrar ×1