tim*_*fly 6 firefox-addon firefox-addon-sdk reactjs
控制台记录某些对象,如对象this.refs
或window
导致TypeError: cyclic object value
终端中的错误.
我的代码非常基本:我正在尝试更改网页上的html(在其中放置反应组件).
Main.js:
var pageMod = require("sdk/page-mod");
var self = require("sdk/self");
var { MatchPattern } = require("sdk/util/match-pattern");
// Create a page mod
// It will run a script whenever a ".org" URL is loaded
// The script replaces the page contents with a message
pageMod.PageMod({
include: /.*wikipedia.org\/wiki\/.*/,
contentScriptFile: [
self.data.url("react-with-addons.js"),
self.data.url("testing.js"),
],
contentScriptWhen: "ready",
// contentStyleFile: self.data.url("style.css"),
});
Run Code Online (Sandbox Code Playgroud)
testing.js:
var AppContainer = React.createClass({displayName: "AppContainer",
componentDidMount: function() {
console.log(this.refs.myRef);
console.log(window);
},
render: function() {
console.log('rendering');
return (
React.createElement("div", {ref: "myRef"})
);
}
});
React.render(React.createElement(AppContainer, null), document.getElementById('content'));
Run Code Online (Sandbox Code Playgroud)
运行后cfx run
,componentDidMount中的日志不会在浏览器控制台和cyclic object value
显示中显示任何内容(尝试将窗口对象记录到控制台).为什么遇到困难?
归档时间: |
|
查看次数: |
14262 次 |
最近记录: |