abstract class Route {
abstract readonly name?: string;
protected abstract pattern: string;
public constructor() {
// Do something with `this.name` and `this.pattern`.
console.log(this.pattern); // Typecheck error
}
abstract handle(): void;
}
Run Code Online (Sandbox Code Playgroud)
这会引发错误,因为this.pattern
不会在构造函数中访问。为什么我无法访问它?
在下面的函数中,我得到了带有属性的textarea对象current
.
这里,嵌套的解构与Start
和End
变量一起工作.但current
变量不起作用.
function someFunction({ current: { selectionStart: Start, selectionEnd: End } }, AppStateSetter) {
// do something with current, Start, and End
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试index.js
使用汇总编译此文件:
import React from "react";
import ReactDOM from "react-dom";
import Grid from "@material-ui/core/Grid";
ReactDOM.render(
<React.StrictMode>
<Grid container>
</Grid>
</React.StrictMode>,
document.getElementById('root')
);
Run Code Online (Sandbox Code Playgroud)
rollup.config.js
:
import { nodeResolve } from '@rollup/plugin-node-resolve';
import babel from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
export default {
input: 'index.js',
output: {
file: 'dist/bundle.js',
format: 'iife'
},
plugins: [
nodeResolve(),
babel({ babelHelpers: 'bundled', exclude: /node_modules/ }),
commonjs(),
],
};
Run Code Online (Sandbox Code Playgroud)
babel.config.json
:
{
"presets": [
"@babel/preset-react",
"@babel/preset-env"
]
}
Run Code Online (Sandbox Code Playgroud)
现在,当我运行时,出现npx rollup -c
此错误:
[!] 错误:无法加载 /home/recursive-beast/Desktop/repositories/myproject/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties(由 …
我用一些代码解决了以下 leetCode 问题:
d
骰子,每个骰子都有f
编号为 1、2、...、f 的面。
返回模 10^9 + 7 的可能方式数来掷骰子,使面朝上的数字总和等于t
.
我制作了两个版本的解决方案代码,一个在 node.js 中使用mathjs,另一个在 python 中使用 math 模块。
在 node.js 中
const { combinations: comb, bignumber: Big } = require("mathjs");
function dice(d, f, t) {
if (t > d * f || t < d) return 0;
var result = Big(0);
var i = 0;
var sign = 1;
var n = t - 1;
var k = t - d;
while …
Run Code Online (Sandbox Code Playgroud) javascript ×3
reactjs ×2
abstract ×1
bignum ×1
class ×1
material-ui ×1
python ×1
react-ref ×1
rollupjs ×1
typescript ×1