我试图将值附加到地图内的数组:
var MyMap map[string]Example
type Example struct {
Id []int
Name []string
}
Run Code Online (Sandbox Code Playgroud)
这是我尝试但我不能指向示例的对象附加到数组.
package main
import (
"fmt"
)
type Example struct {
Id []int
Name []string
}
func (data *Example) AppendExample(id int,name string) {
data.Id = append(data.Id, id)
data.Name = append(data.Name, name)
}
var MyMap map[string]Example
func main() {
MyMap = make(map[string]Example)
MyMap["key1"] = Oferty.AppendExample(1,"SomeText")
fmt.Println(MyMap)
}
Run Code Online (Sandbox Code Playgroud) 我遇到了React.js的问题以及它处理存储在变量中的文本的方式.
以下是使用DOM的方式:
let text = "Must credit to "https://indepthguide.com/" not Flickr.\nCopy Link Address: <a href=\"https://indepthguide.com/\" rel=\"nofollow\">indepthguide.com/</a>"
document.getElementById("root").innerHTML = text;Run Code Online (Sandbox Code Playgroud)
<p id="root"></p>Run Code Online (Sandbox Code Playgroud)
这就是它在React.js中的样子.
var text = "Must credit to "https://indepthguide.com/" not Flickr.\nCopy Link Address: <a href=\"https://indepthguide.com/\" rel=\"nofollow\">indepthguide.com/</a>";
class Text extends React.Component {
render() {
return <h3 >{
text
} < /h3>;
}
}
ReactDOM.render( <
Text / > ,
document.getElementById('root')
)Run Code Online (Sandbox Code Playgroud)
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id="root"></div>Run Code Online (Sandbox Code Playgroud)
我尝试new DOMParser();但没有成功,因为它开始抛出错误,我不确定如何处理它.我真的不知道该怎么做,现在试着做了很长时间:D.