我正在 Typescript 中创建一个 HTMLInputElement,我打算通过将输入元素的type字段设置为 来将其用作“滑块” "range"。
根据 MDN Web Docs,我可以通过创建 HTMLDatalistElement 的实例、为数据列表提供并通过滑块的字段id引用数据列表来使该滑块更加精美。这不仅会给我的滑块一些刻度线来表示滑块光标当前所在的位置,而且我还可以设置数据列表的 HTMLOptionElement字段来引入带标签的刻度线。idlistlabel
来源:https ://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/range#adding_labels
然而,Deno/TS-Node 抱怨这个错误:
error: TS2540 [ERROR]: Cannot assign to 'list' because it is a read-only property.
inputElement.list = datalistId;
Run Code Online (Sandbox Code Playgroud)
谷歌浏览器抱怨这个错误:
Uncaught TypeError: Cannot set property list of #<HTMLInputElement> which has only a getter
Run Code Online (Sandbox Code Playgroud)
由于 MDN Web 文档清楚地表明该字段是要使用的,因此我尝试通过以下方式忽略 Deno/TS-Node 错误来消除它:
// @ts-ignore
Run Code Online (Sandbox Code Playgroud)
该解决方案不起作用,并导致上述 Google Chrome 运行时错误。
我不明白为什么在通过文件构造 HTMLInputElement 时允许设置此字段.html,但在通过 Javascript/Typescript 动态创建 HTMLInputElement 实例时不允许使用它。能够动态设置滑块的刻度线标签会非常好。
我正在尝试使用标准 deno fs 模块,但编译器抱怨没有--unstable标志。
import { writeJson, readJson } from "https://deno.land/std/fs/mod.ts";
const json = await readJson("input.txt");
console.log(`JSON: ${JSON.stringify(json)}`);
await writeJson("input.txt", json);
Run Code Online (Sandbox Code Playgroud)
我的 deno 版本:
deno 1.0.0-rc2
v8 8.4.300
typescript 3.8.3
Run Code Online (Sandbox Code Playgroud)
我总是遇到相同的错误。它们似乎与缺少模块有关,但我不确定可能缺少什么。
? deno-api denoa filetest.ts
Compile file:///home/astone/source/deno-api/filetest.ts
error: TS2339 [ERROR]: Property 'utime' does not exist on type 'typeof Deno'.
await Deno.utime(dest, statInfo.atime, statInfo.mtime);
~~~~~
at https://deno.land/std/fs/copy.ts:90:16
TS2339 [ERROR]: Property 'utimeSync' does not exist on type 'typeof Deno'.
Deno.utimeSync(dest, statInfo.atime, statInfo.mtime);
~~~~~~~~~
at https://deno.land/std/fs/copy.ts:101:10
TS2339 [ERROR]: Property 'symlink' does …Run Code Online (Sandbox Code Playgroud) 由于 Deno 几天前刚刚发布了稳定版本,有没有可能的方法在 Deno 中使用 firebase-admin?
当使用命令运行应用程序时deno run app.ts,它给出一个error: Uncaught PermissionDenied
error: Uncaught PermissionDenied: access to environment variables, run again with the --allow-env flag
at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
at Object.sendSync ($deno$/ops/dispatch_json.ts:72:10)
at Object.toObject ($deno$/ops/os.ts:33:12)
at file:///opt//deno/app.ts:5:22
Run Code Online (Sandbox Code Playgroud) 当我尝试运行我的第一个 deno 程序时收到错误消息
deno run server.ts
Run Code Online (Sandbox Code Playgroud)
错误 : Uncaught PermissionDenied: network access to "0.0.0.0:8000", 再次运行 --allow-read 标志
我正在尝试使用 docker image 设置 Deno hayd/alpine-deno。基本版本(基于文档)运行良好,但我想添加一些文件观察器denon来增强开发过程。当我使用 docker-compose 构建容器时,我得到
Building http-service
Step 1/10 : FROM hayd/alpine-deno:1.1.1
---> 265a525bcfa5
Step 2/10 : EXPOSE 3000
---> Using cache
---> f1dfcd77a566
Step 3/10 : WORKDIR /app
---> Using cache
---> df9c2dc916b4
Step 4/10 : USER deno
---> Using cache
---> c05fbfb4d1e7
Step 5/10 : COPY deps.ts .
---> Using cache
---> 250bf28f8b50
Step 6/10 : RUN deno cache deps.ts
---> Using cache
---> e32e9f80f625
Step 7/10 : ADD . .
---> …Run Code Online (Sandbox Code Playgroud) 我正在使用 fetch api 在 Deno 中下载图像。在 Response 对象上,我正在调用 arrayBuffer() 方法,以获取响应的最终数据:
const response = await fetch('https://www.example.com/someimage.jpg')
const data = await response.arrayBuffer();//This returns an arrayBuffer.
Run Code Online (Sandbox Code Playgroud)
然后我想把这些数据写入一个文件,就像你在 Node 中做的那样:
await Deno.writeFile('./someimage.jpg' ,data)
Run Code Online (Sandbox Code Playgroud)
图像变成空的。文档说 Deno.writeFile 需要一个 Uint8Array,但我不知道如何从 arrayBuffer 构造它,它是从 fetch 响应接收的。
如何才能做到这一点?
我从 Drash ( https://github.com/drashland/deno-drash )下载了示例应用程序
$ deno run --allow-run --allow-read --allow-write --allow-net https://deno.land/x/drash/create_app.ts --api
并尝试添加一个新测试,其中:
Deno.test("HomeResource - GET /", async () => {
const response = await fetch("http://localhost:1557", {
method: "GET",
});
assertEquals(response.status, 200);
assertEquals(
await response.json(),
JSON.stringify({
success: true,
message: "GET request received.",
}),
);
});
Run Code Online (Sandbox Code Playgroud)
这是错误信息
Server listening: http://localhost:1557
running 5 tests
test HomeResource - GET / ... FAILED (9ms)
test HomeResource - POST / ... ok (2ms)
test HomeResource - PUT / …Run Code Online (Sandbox Code Playgroud) 我一直无法找到正确的语法/URL 来在 Deno 程序中导入 Lodash。我试过这个:
import _ from 'https://deno.land/x/lodash@4.17.19/lodash.js';
Run Code Online (Sandbox Code Playgroud)
这给出了错误“未捕获的语法错误:请求的模块‘https://deno.land/x/lodash@4.17.19/lodash.js’不提供名为‘default’的导出”。
然后我尝试了这个:
import * as lodash from 'https://deno.land/x/lodash@4.17.19/lodash.js';
Run Code Online (Sandbox Code Playgroud)
这似乎给了我一个空的模块对象。
我想看一个从 Deno 程序访问 Lodash 任何功能的示例。
我从这个链接“https://deno.land/x/denodb@v1.0.23/mod.ts”中使用了 denodb Lib 然后我得到了以下错误:
error: Import 'https://raw.githubusercontent.com/denjucks/dex/master/mod.ts' failed: 404 Not Found
at https://deno.land/x/denodb@v1.0.23/deps.ts:3:0
Run Code Online (Sandbox Code Playgroud)
那是因为 DEX 库从此链接“https://raw.githubusercontent.com/denjucks/dex/master/mod.ts”移出。
所以我尝试了这个解决方案链接(他们分叉了 denodb 并更改了 deps.ts 中的 dex url)。
之后,我收到以下错误:
error: An unsupported media type was attempted to be imported as a module.
Specifier: https://github.com/takxlz/denodb/blob/master/mod.ts
MediaType: Unknown
Run Code Online (Sandbox Code Playgroud)
知道如何解决这个错误吗?(我也试过清理缓存,但仍然发生同样的错误)
谢谢。
deno ×10
javascript ×2
docker ×1
dockerfile ×1
firebase ×1
html ×1
import ×1
lodash ×1
ts-node ×1
typescript ×1