请让我知道如何在其中包含谷歌分析preact
?我发现有人做了react
如下
componentDidMount() {
window.ga = window.ga || function() { (ga.q = ga.q || []).push(arguments) }; ga.l = +new Date;
const account = this.props.account;
// const scriptProtocol = ("https:" === document.location.protocol ? "https://ssl" : "http://www");
const scriptSrc = `//google-analytics.com/analytics.js`;
jQuery.getScript(scriptSrc, () => {
// Track Route changes
ga("create", account, "auto");
if(this.props.history) {
this.props.history.listen((newLocation) => {
ga("send", "pageview", newLocation.pathname);
});
}
});
}
但问题是jQuery
上面代码中使用的这个人undefined
。请让我知道如何解决它。