为什么用花括号导入会导致问题?

时间:2019-04-23 00:44:08

标签: reactjs redux react-redux react-router

我已经检查了this question的大小写之间的区别。

就我而言,我有一堂课:

var

如果我使用
class PathResolver extends Component { //content } export default connect()(PathResolver);
而不是
import { PathResolver } from '/path';
它将抱怨:import PathResolver from '/path';

当类名是“ PathResolver”时,这两个导入语句应该相同,但是似乎带有花括号的导入语句找不到连接的“ PathResolver”,为什么?

1 个答案:

答案 0 :(得分:1)

如果您也导出类,也可以这样做。

public class Tester042219 {
    public static void main(String[] args) {
        B x = new B(1);
        B x2 = new B(1);
        B x3 = new B(99);

        System.out.println("B == B: Works? " 
            + (x.equals(x2) && !x.equals(x3)));

        C y = new C("A");
        C y2 = new C("A");
        C y3 = new C("AAAA");

        System.out.println("C == C: Works? " 
            + (y.equals(y2) && !y.equals(y3)));
    }

    public static abstract class A<T> {
        public abstract T getVar();

        @Override
        public int hashCode() {
            final int prime = 31;
            int result = 1;
            result = prime * result + getVar().hashCode();
            return result;
        }

        @Override
        public boolean equals(Object obj) {
            if (this == obj) return true;
            if (obj == null) return false;
            if (getClass() != obj.getClass()) return false;

            A<?> other = (A<?>) obj;
            return getVar().equals(other.getVar());
        }
    }

    public static class B extends A<Integer> {
        private int var = 0;
        public B(int var) { this.var = var; }

        @Override
        public Integer getVar() { return var; }
    }

    public static class C extends A<String> {
        private String var = "";
        public C(String var) { this.var = var; }

        @Override
        public String getVar() { return var; }
    }

}

由于当前您的组件被包装在redux中,因此您将无法访问它