汉堡菜单不适用于样式化的组件

时间:2018-12-11 21:56:57

标签: css reactjs styled-components

我真的很困惑为什么它不起作用。我正在使用样式组件库,实际上我的汉堡菜单有问题。仅在显示复选框时,它才会更改。它应该只能使用CSS,但没有任何建议吗?

<HamburgerCnt>
      <input type="checkbox" name="check" />
      <label htmlFor="check" />
</HamburgerCnt>

和Component看起来像这样

@Configuration
public class FieldFormatConfirguration {

    @Autowired
    private ResourceLoader resourceLoader;

    private List<String> loadConfigFile() throws IOException {
        List<String> messageFields = new ArrayList<>();

        Resource res = resourceLoader.getResource("classpath:myconfig.txt");

        File file = res.getFile();
        Stream<String> stream = Files.lines(Paths.get(file.getPath()));
        stream.forEach(item -> {System.out.println(item); messageFields.add(item);});
        stream.close();

        return messageFields;
    }

    @Bean
    public List<Function<String, String>> configFunctions() throws IOException {
        List<String> messageFields = loadConfigFile();
        List<Function<String, String>> configFunctions = new ArrayList<>();
        // Config configFunctions based on messageFields...
        return configFunctions;
    }
}

1 个答案:

答案 0 :(得分:1)

您应将check用作输入的id,而不是其名称。

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label#Using_the_for_attribute