【发布时间】:2016-11-02 13:22:31
【问题描述】:
我正在使用 React.js,并尝试在我的渲染函数中检索以下 html 元素的地址链接:
<a class="form-label" href={this.link.bind(this)}> Link </a>
功能链接如下:
link() {
return "192.168.3.9:8080/cars/" + this.state.carType;
}
this.state.carType 将汽车类型存储为字符串。
但是,这是我被定向到的链接:
localhost:8080/function%20()%20%7B%20[native%20code]%20%7D
有什么想法吗?
谢谢。
【问题讨论】:
-
我认为您应该使用 onClick 事件
-
你不能把那个网址放在href中吗?
href={"192.168.3.9:8080/cars/" + this.state.carType}
标签: javascript html url reactjs