以下调用将在Yahoo Finance API中搜索名称中包含"Yahoo"的股票:
http://d.yimg.com/autoc.finance.yahoo.com/autoc?query=yahoo®ion=US&lang=en-US&row=ALL&callback=YAHOO.Finance.SymbolSuggest.ssCallback
Run Code Online (Sandbox Code Playgroud)
不幸的是,结果数量限制为10,这会导致某些搜索查询出现问题.有没有办法增加限额?
我正在阅读一本关于React和Universal应用程序的书,其中作者声称以下是将初始状态从服务器传递到客户端的最佳实践:
server.js
import React from 'react';
import {renderToStaticMarkup} from 'react-dom/server';
import Myapp from '../MyApp';
import api from '../services';
function renderPage(html, initialData) {
return `
<html>
<body>
${html}
</body>
<script>
window.__INITIAL_STATE__ = ${JSON.stringify(initialData)};
</script>
<script src="bundle.js"></script>
</html>
`;
}
export default function(request, reply) {
const initialData = api.getData();
const html = renderToStaticMarkup(<MyApp />);
reply(renderPage(html, initialData);
}
Run Code Online (Sandbox Code Playgroud)
然后,在客户端中,您将读出如下数据:
bundle.js
const initialData = window.__INITIAL_STATE__ || {};
const mountNode = document.getElementById('root');
ReactDOM.render(<MyApp />, mountNode);
Run Code Online (Sandbox Code Playgroud)
据我所知,初始状态首先转换为字符串,然后作为全局对象文字附加到窗口对象.
这个解决方案看起来非常粗糙.这本书是在2016年中期发布的.使用的方法window.__INITIAL_STATE__仍然是如何做到这一点还是有更好的解决方案?
例如,我可以想象,可以在单独的微服务调用中提供初始状态,然后也可以比将数据直接嵌入到文档中更好地缓存,因为这样初始状态数据必须每次传输页面刷新的时间,即使数据没有改变.
由于我不是律师,因此JavaMail API的许可协议令人困惑.
我想在电子邮件服务的服务器端使用JavaMail作为闭源商业项目,它为我们的客户提供电子邮件功能.
那么,我是否可以使用JavaMail,或者我是否需要支付许可费或在开源许可下发布我的代码或类似的东西?
JavaMail是否支持通过服务器推送通知新电子邮件?
如果是,那么该文件在哪里?如果没有,是否有可以执行此操作的库?
我在我的移动启用网站上使用iScroll(在这里使用iPhone)在div内滚动.
在这个div中,我有一个像这样固定高度的iframe:
<body>
<div id="iscroller">
<iframe id="theIframe"></iframe>
Other stuff
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
现在,在div中滚动时,一切都按预期工作,但是当iframe上的滚动手势开始时我无法滚动.
这个问题在这里描述得很好:https://github.com/cubiq/iscroll/issues/41
所以,我通过应用pointer-events:noneiframe 来使用该帖子中的css解决方法.
现在滚动工作完美但我无法点击iframe中定义的任何链接,因为iframe上的所有点击/触摸事件似乎都被阻止了pointer-events: none.
所以我认为:
"好的,当用户滚动时,我需要
pointer-events:none.如果他没有滚动(而是点击),我必须设置pointer-events:auto才能让点击/触摸事件通过."
所以我这样做了:
CSS
#theIframe{pointer-events:none}
Run Code Online (Sandbox Code Playgroud)
JavaScript的
$("#theIframe").bind("touchstart", function(){
// Enable click before click is triggered
$(this).css("pointer-events", "auto");
});
$("#theIframe").bind("touchmove", function(){
// Disable click/touch events while scrolling
$(this).css("pointer-events", "none");
});
Run Code Online (Sandbox Code Playgroud)
即使添加此功能也不起作用:
$("#theIframe").bind("touchend", function(){
// Re-enable click/touch events after releasing
$(this).css("pointer-events", "auto");
});
Run Code Online (Sandbox Code Playgroud)
无论我做什么:滚动不起作用或点击iframe内的链接不起作用.
不行.有任何想法吗?
我在我的应用程序中使用了一些非常简单的CSS3过渡,如下例所示,我尝试从左到右滑动div容器:
<div id="navi">
<form>
<input>...</input>
</form>
<ul>
<li>...</li>
<li>...</li>
<li>...</li>
<li>...</li>
<li>...</li>
<li>...</li>
<li>...</li>
<li>...</li>
<li>...</li>
<li>...</li>
<li>...</li>
<li>...</li>
</ul>
</div>
<div id="bg">
<img src="...">
<img src="...">
<img src="...">
<img src="...">
<img src="...">
<img src="...">
<img src="...">
<img src="...">
<img src="...">
<img src="...">
<img src="...">
<img src="...">
</div>
#navi{
z-index:2;
position:fixed;
-webkit-transform:translateZ(0);
-webkit-transform-style: preserve-3d;
-webkit-backface-visibility: hidden;
-webkit-transition:left 0.5s;
left:0;
top:0;
bottom:0;
width:95%;
overflow-x:hidden;
overflow-y:auto;
-webkit-overflow-scrolling:touch;
}
.slidein{
left:500px;
}
Run Code Online (Sandbox Code Playgroud)
要滑入/滑出div,我会:
$("#navi").toggleClass("slidein");
Run Code Online (Sandbox Code Playgroud)
在我的iPhone 4s上,这种过渡非常顺利.在iPhone 4上表现可怕.
我能做些什么来提高性能吗?有没有"黄金法则"或最佳做法?
到目前为止我只知道:
-webkit-transform:translateZ(0)触发硬件加速使用Hibernate和lazy = true模式从数据库加载对象列表时遇到了一些问题.希望有人可以帮助我.
我在这里有一个名为UserAccount的简单类,如下所示:
public class UserAccount {
long id;
String username;
List<MailAccount> mailAccounts = new Vector<MailAccount>();
public UserAccount(){
super();
}
public long getId(){
return id;
}
public void setId(long id){
this.id = id;
}
public String getUsername(){
return username;
}
public void setUsername(String username){
this.username = username;
}
public List<MailAccount> getMailAccounts() {
if (mailAccounts == null) {
mailAccounts = new Vector<MailAccount>();
}
return mailAccounts;
}
public void setMailAccounts(List<MailAccount> mailAccounts) {
this.mailAccounts = mailAccounts;
}
}
Run Code Online (Sandbox Code Playgroud)
我通过以下映射文件在Hibernate中映射此类:
<?xml version="1.0"?>
<!DOCTYPE …Run Code Online (Sandbox Code Playgroud) 我为iPhone,Android和WP8设置了PhoneGap项目.
要刷新UIWebView的内容,我想为用户提供pull-to-refresh功能.
由于其他限制,我无法使用像iScroll这样的JavaScript解决方案.
有没有办法使用本机 pull-to-refresh功能重新加载UIWebView的当前内容?
我为iPhone创建了一个PhoneGap应用程序,它通过webview中的JavaScript使用地理定位.
当我第一次运行应用程序时,它会提示我允许这个应用程序的地理位置.
当我点击"确定"时,它会再次提示我同样的问题,但这一次它说"index.html"想要使用地理位置的许可.
这是有道理的,因为iOS可能希望允许第一次允许应用程序本身的地理定位,并且第二次浏览器需要权限.
但是,由于不会带来出色的用户体验:
如何防止此双重提示?(如果可以防止第二次提示,我就够了)
由于我来自Java背景,因此我不是Objective-C专家,因此需要努力修改以下代码:
- (void) loadHTML:(CDVInvokedUrlCommand*)command
{
NSString* callbackId = command.callbackId;
NSArray *arguments = command.arguments;
CDVPluginResult* pluginResult;
if (webView)
{
NSString *stringObtainedFromJavascript = [arguments objectAtIndex:0];
[webView loadHTMLString:stringObtainedFromJavascript baseURL:baseURL];
if (screenNeedsInit) {
[self makeScreenVisible];
}
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString: WEBVIEW_OK];
[self writeJavascript: [pluginResult toSuccessCallbackString:callbackId]];
}
else
{
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString: WEBVIEW_UNAVAILABLE];
[self writeJavascript: [pluginResult toErrorCallbackString:callbackId]];
}
}
Run Code Online (Sandbox Code Playgroud)
编译器会抱怨,这两个,writeJavascript以及toErrorCallbackString已被取消,我应该代替他们evalJS和pluginResult.
所以,我的第一步是改变这一行:
[self writeJavascript: [pluginResult toSuccessCallbackString:callbackId]];
Run Code Online (Sandbox Code Playgroud)
像这样:
[self.commandDelegate evalJs: [pluginResult toSuccessCallbackString:callbackId]];
Run Code Online (Sandbox Code Playgroud)
所以,这个工作,但我仍然需要更换toSuccessCallbackString有sendPluginResult …
cordova ×3
ios ×3
iphone ×3
html5 ×2
iscroll ×2
jakarta-mail ×2
java ×2
javascript ×2
ajax ×1
android ×1
callback ×1
css3 ×1
ecmascript-6 ×1
email ×1
geolocation ×1
hibernate ×1
iframe ×1
json ×1
licensing ×1
objective-c ×1
performance ×1
push ×1
reactjs ×1
rest ×1
scroll ×1
yahoo-api ×1