我现在正在建立一个使用id作为书签的网站,以便用户在单击特定链接时可以转到特定段落。
例如 用户单击www.abc.com#my-paragraph
用户将转到
getline()
在网站上
在除IE之外的所有浏览器中均可使用。如何解决问题?谢谢!
答案 0 :(得分:0)
如果您的段落为import React, {
Component
} from "react";
import "./solar.css";
import firebase from "firebase";
import {
config
} from "../config";
let app = firebase.initializeApp(config);
let database = app
.database()
.ref()
.child("values")
.child("Voltage");
class Solar extends Component {
state = {
voltage: 0
};
componentDidMount() {
// Store reference to the "on value" callback for deregistering
// the event when the Solar component unmounts
this.valueChangeCallback = database.on("value", snap => {
this.setState({
voltage: snap.val()
});
console.log(snap.val());
})
}
componentWillUnmount() {
// If a valueChangeCallback exists from former mount then deregister
// this callback from you database instance
if(this.valueChangeCallback) {
database.on("value", this.valueChangeCallback);
this.deregisterCallback = '';
}
}
}
,则需要添加:
<p id="my-paragraph">hello</p>
到html中的按钮。