据我所知,浏览器的默认主页/搜索提供商没有公开API曝光.那么谷歌如何知道这一点呢?只有当Google不是我浏览器上的默认主页/默认搜索提供商时,它才会出现.
我只能假设他们是从众多变量推断出来的,例如推荐者.我无法成功地深入了解Google编译的JavaScript.我甚至不确定它是在客户端还是服务器端检测到的.
我在Firefox 44上,但我也在Chrome上看过这些横幅.
我有一个基本的Vue.js对象:
var playlist = new Vue({
el : '#playlist',
data : {
entries : [
{ title : 'Oh No' },
{ title : 'Let it Out' },
{ title : 'That\'s Right' },
{ title : 'Jump on Stage' },
{ title : 'This is the Remix' }
]
}
});
Run Code Online (Sandbox Code Playgroud)
HTML:
<div id="playlist">
<div v-for="entry in entries">
{{ entry.title }}
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我也使用拖放库(dragula)来允许用户重新排列#playlist div.
但是,在用户使用dragula重新排列播放列表后,此更改不会反映在Vue中playlist.entries,只会在DOM中反映出来.
我已经连接到dragula事件来确定移动元素的起始索引和结束索引.更新Vue对象以反映新订单的正确方法是什么?
我正在处理一个需要报告错误发生的网络工作者.通常,我可以worker.onerror用来监听从工作者抛出的任何错误.但是,当错误发生在Web工作者的承诺中时,我无法弄清楚如何将错误重新发送回来worker.onerror.
请原谅奇怪的代码片段,因为这似乎是证明工人行为的唯一方法.(工作人员在HTML部分中定义).
function getInlineJS() {
var js = document.querySelector('[type="javascript/worker"]').textContent;
var blob = new Blob([js], {
"type": "text\/plain"
});
return URL.createObjectURL(blob);
}
var worker = new Worker(getInlineJS());
worker.onerror = function(err) {
document.getElementById('errors').innerHTML +=
"error " + err.message + '\n';
}
worker.onmessage = function (msg) {
console.log("message recieved", msg);
document.getElementById('messages').innerHTML +=
"message " + msg.data + '\n';
}
worker.postMessage("run");
worker.postMessage("promise");Run Code Online (Sandbox Code Playgroud)
should write "Normal Error and In Promise Error" below and in console (promise error only occurs in console …Run Code Online (Sandbox Code Playgroud)