我想在浏览器和服务器上使用浏览器代码.我的代码基本上是React组件.我想app.js在浏览器和服务器上浏览代码,获取一个编译表并使用它们:
// in a browser
<script src="/js/app.js" type="text/javascript" charset="utf-8" async></script>
// on a server
var App = require('../assets/js/react/app');
Run Code Online (Sandbox Code Playgroud)
但是浏览器window根据我的理解不知道对象.我无法require在服务器端浏览代码,抛出错误:
if (window.location.pathname == '/foo') {
^
ReferenceError: window is not defined
Run Code Online (Sandbox Code Playgroud)
这是代码:
... many React components go here ...
// and here is a call to window and its properties
if(window.location.pathname == '/foo') {
ReactDOM.render(
<MsgBox data={window.data} oInfo={window.oInfo} />,
document.getElementById('content-body')
);
ReactDOM.render(
<SearchBox />,
document.getElementById('searchBox')
);
}
Run Code Online (Sandbox Code Playgroud)
browserify-handbook说这global是一个别名window:
在节点中,
global …
这是按钮默认大小的屏幕截图(http://www.material-ui.com/#/components/floating-action-button)
mini按钮的大小为 40x40px。有没有一种简单的方法可以将尺寸缩小到 30x30 或任何其他自定义尺寸?说,通过提供prop={{size: '30:30'}}或以某种方式通过样式。
当您在开发者网站上注册为PayPal开发者时,沙盒会自动为您创建一个业务测试帐户(例如
pp.merch01-facilitator@example.com)及其关联的NVP / SOAP API测试凭据。还会自动创建一个默认的个人帐户(例如pp.merch01-buyer@example.com)
贝宝(PayPal)很棒,但是他们的密码在哪里?如果没有密码,这些帐户几乎没有用。PayPal开发人员是否真的忘记为这些帐户添加密码?因为既没有链接,也没有选项,也没有字段,也没有任何东西可以获取或分配密码。
我想使用 CLI 为安全组设置 IP 地址。但出于某种原因,AWS 会引发错误。并且该值绝对正确,因为我设置的值与执行命令时设置的值相同。怎么了?为什么会出现这个错误?
$ aws ec2 authorize-security-group-ingress --protocol tcp --port 22 --cidr 'xx.xx.xxx.xx/32' --group-id sg-xxxxxxxx
An error occurred (InvalidParameterValue) when calling the AuthorizeSecurityGroupIngress operation: CIDR block xx.xx.xxx.xx\32 is malformed
Run Code Online (Sandbox Code Playgroud) 在 Chrome 控制台中:
# One
class A {
constructor(x) { this.x = x }
}
class A {
constructor(x, y) { this.x = x; this.y = y }
}
VM602:1 Uncaught SyntaxError: Identifier 'A' has already been declared(…)
# Two
class A {
constructor(x) { this.x = x }
}
delete A
true
class A {
constructor(x) { this.x = x }
}
VM805:1 Uncaught SyntaxError: Identifier 'A' has already been declared(…)
# Three
A = null
null
class A …Run Code Online (Sandbox Code Playgroud) Node.js 的util.inspect函数的问题。我用它来为 Node.js 控制台输出着色并格式化对象。除了util.inspect打印所有这些\r\n字符外,一切正常。
这个例子。给定一个文件:
// foo.js
console.log("css:\n", util.inspect(css, { depth: 5, colors: true }), '\n');
Run Code Online (Sandbox Code Playgroud)
输出:
如何util.inspect不打印所有这些\r\n字符?
在网络开发中,您可以手动打开DevTools > Application和编辑。Local Storage
RN中有类似的功能吗?
我已经安装了Reactotron,但没有此功能,它只显示其中的内容AsyncStorage,没有编辑。
这是什么意思?(https://facebook.github.io/react-native/docs/scrollview)
请记住,滚动视图必须具有一定的高度才能工作
谁必须拥有所谓的边界高度?ScrollView本身?还是它的父母?还是它的孩子?
<SafeAreaView style={{height: ...}}> <= this?
<ScrollView style={{height: ...}}> <= this?
<View style={{height: ...}}> <= this?
....
</View>
</ScrollView>
</SafeAreaView>
Run Code Online (Sandbox Code Playgroud) FB如何刷新页面而不重新加载它(xmlHttpRequest)但后退/前进按钮仍然像往常一样工作?
这不是关于使用history.pushState()方法.PushState()仅更改URL字符串,但在单击"后退"按钮后不执行任何操作以获取上一页面.所以它有点不同.
这是我的代码和示例.
我有这样的网站(看下面的图片).Header-div和Content-div.在您第一次打开它时,URL是mysite.com/page1.php.我想要在不重新加载页面的情况下更改Content-div中的内容.新的信息应该出现在Content-div中.并且URL应该更改为mysite.com/page2.php.
这是HTML代码.
<div id="content"></div>
<a href="" id="relaodLink">Reload Content</a>
Run Code Online (Sandbox Code Playgroud)
这是它的JS代码.
document.getElementById("relaodLink").onclick = function() {
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", "page2.php", true);
xmlHttp.send();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
document.getElementById("content").innerHTML = xmlHttp.responseText;
}
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
所以Header不应该在按下之后重新加载relaodLink,只是Content-div中的内容发生变化.最重要的是:URL应该像页面真正重新加载一样改变.后退按钮允许转到mysite.com/page1.php然后转发按钮允许mysite.com/page2.php再次返回.使用history.pushState()方法它不起作用.但在FB Back and Forward Buttons工作正常.怎么做?
一只忙碌的猫http://www.ljplus.ru/img4/a/_/a_ya_vishe/primer-xmlhttp_3.jpg
paypal ×2
react-native ×2
reactjs ×2
amazon-ec2 ×1
asyncstorage ×1
back-button ×1
browserify ×1
console.log ×1
facebook ×1
javascript ×1
layout ×1
markup ×1
material-ui ×1
newline ×1
node.js ×1
output ×1
page-refresh ×1
react-jsx ×1
yoga-x1 ×1