小编Chu*_*uck的帖子

如何访问LoadableComponent和Route中的子项?

在我的主要组件中,我创建了一个ref:

this.transfernewRef = React.createRef();
Run Code Online (Sandbox Code Playgroud)

并将其分配给我的组件,该组件嵌入在路径中:

<Route path="/new" render={(props) => <TransferNew {...props} origin={this.state.origin} token={this.state.token} ref={this.transfernewRef} />}/>
Run Code Online (Sandbox Code Playgroud)

我的组件TransferNew也使用react-loadable及其Loadable组件动态加载.如果我打印this.transfernewRef.current,我会得到一个LoadableComponent对象:

在此输入图像描述

如何从那里访问我的组件TransferNew?我似乎找不到合适的方法来做到这一点.我只想调用TransferNew的一个函数,所以就这样:

this.transfernewRef.current.<something>.myFunction()

谢谢.

reactjs react-router react-loadable

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

如何将模板字符串呈现为HTML?

假设我有一个简单的模板字符串:

const foo = `<div>foo</div>`;
Run Code Online (Sandbox Code Playgroud)

如何将该模板字符串呈现为HTML?如果执行以下操作,它会将其呈现为纯文本:

return({ foo });

输出:

<div>foo</div>
Run Code Online (Sandbox Code Playgroud)

预期产量:

foo
Run Code Online (Sandbox Code Playgroud)

ecmascript-6 reactjs

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

使用Spring Boot/Thymeleaf"没有消息可用"

我正在使用Thymeleaf的Spring Boot,我正在尝试访问一个简单的网页.构建项目时我没有任何错误.访问时只有这一个localhost:8080/greeting:

Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Fri Dec 02 15:36:04 CET 2016
There was an unexpected error (type=Not Found, status=404).
No message available
Run Code Online (Sandbox Code Playgroud)

我有一个控制器:

package controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class UserController {

    @RequestMapping("/greeting")
    public String user(@RequestParam(value = "name", required = false, defaultValue = "World") String name, Model model){
        model.addAttribute("name",name);
        return "greeting";
    }

}
Run Code Online (Sandbox Code Playgroud)

主要:

package boot; …
Run Code Online (Sandbox Code Playgroud)

java spring thymeleaf spring-boot

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