小编Bra*_*ier的帖子

当路径改变时,Webpack从错误的URL加载

我正在写一个反应应用程序,当我导航到一切正常时localhost:3000,但是当我尝试去时localhost:3000/foo/page,我收到一条错误消息,告诉我localhost:3000/foo/bundle.js无法加载.

对我来说,这似乎是Webpack在bundle.js的错误位置查找的问题,但我不确定.如何让应用程序始终查看localhost:3000bundle.js?

这是我的一些webpack配置.

var TARGET = process.env.npm_lifecycle_event;
var ROOT_PATH = path.resolve(__dirname);
var APP_PATH = path.resolve(ROOT_PATH, 'app');
var BUILD_PATH = path.resolve(ROOT_PATH, 'dist');

process.env.BABEL_ENV = TARGET;
var common = {
    entry: APP_PATH,

    output: {
        path: BUILD_PATH,
        filename: 'bundle.js'
    },

    module: {
        loaders: [
            {
                test: /\.jsx?$/,
                loaders: ['babel'],
                include: APP_PATH
            },
            {
                test: /\.svg$/,
                loader: 'url-loader?limit=8192',
                include: APP_PATH
            },
            {
                test: /\.png$/,
                loader: 'url-loader?limit=8192',
                include: APP_PATH
            },
            {
                test: /\.ico$/,
                loader: 'url-loader?limit=8192',
                include: APP_PATH
            }
        ] …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs webpack webpack-dev-server

8
推荐指数
1
解决办法
3684
查看次数

如何解决PintOS无法识别的字符\ x16

我在家用计算机上下载并设置了PintOS和依赖项,但是当我尝试运行时pintos run alarm-multiple,我收到错误:

Unrecognized character \x16; marked by <-- HERE after if ($<-- HERE near column 7 at ~/code/pintos/src/utils/pintos line 911.

该行上有^V同步空闲控制字符.我无法找到有关此问题的任何信息; 看起来我是唯一一个体验它的人.

我安装了Perl v5.26.0.

perl pintos

6
推荐指数
2
解决办法
2443
查看次数

通过高阶组件的默认 prop 类型

通过 HOC 传递组件会导致 typescript 编译器丢失 defaultProps 信息。例如

themed.tsx

export interface ThemedProps {
    theme: {};
}

type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
export type Subtract<T extends K, K> = Omit<T, keyof K>;

const themed = <P extends ThemedProps = ThemedProps>(
    ComponentToWrap: React.ComponentType<P>
) => {
    return class ThemeWrappedComponent extends React.Component<
         Subtract<P, ThemedProps>
    > {
        static displayName = `themed(${ComponentToWrap.displayName})`;

        theme = () => {
            return {}
        };

        render() {
            return (
                <ComponentToWrap
                    {...this.props as P}
                    theme={this.theme()}
                /> …
Run Code Online (Sandbox Code Playgroud)

javascript typescript reactjs higher-order-components

1
推荐指数
1
解决办法
714
查看次数

Typescript返回值或curried函数

鉴于以下Typescript代码,我收到一个错误

TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'AddReturnType' has no compatible call signatures.

为什么不能AddReturnType使用该呼叫?

type AddReturnType = number | ((arg0: number) => number);
function add(x: number, y?: number) : AddReturnType {
    if (!y) {
        return (val) => val + y;
    }
    return x + y;
}

add(1)(2);
Run Code Online (Sandbox Code Playgroud)

javascript currying typescript

0
推荐指数
1
解决办法
36
查看次数