我正在使用 firebase 云函数,第一次看到 cors 然后将 origin 设置为 true .. 但是这样任何人都可以访问我的函数,所以我寻找了一种只允许特定域访问我的云函数的方法,我得到了来自 cors github 页面的代码并尝试了它,但我在等待和等待后意外关闭了连接。
这是我的函数 index.js --
const functions = require('firebase-functions');
const cors = require('cors');
var whitelist = ['http://example1.com', 'http://example2.com']
var corsOptionsDelegate = function (req, callback) {
var corsOptions;
if (whitelist.indexOf(req.header('Origin')) !== -1) {
corsOptions = { origin: true } // reflect (enable) the requested origin in the CORS response
}else{
corsOptions = { origin: false } // disable CORS for this request
}
callback(null, corsOptions) // callback expects two parameters: …Run Code Online (Sandbox Code Playgroud) 我有这个https://codepen.io/anon/pen/RgQOWz
放置任何值,当重复单击减少/减少时,输入框文本将突出显示哪个不是我想要发生的.
我试过user-select: none但仍然没有任何效果.
$(".increment").click(function() {
var score1 = $(".score").val();
score1++;
$(".score").val(score1);
});
$(".decrement").click(function() {
var score1 = $(".score").val();
if (score1 == 0) {} else {
score1--;
$(".score").val(score1);
}
});
$(function() {
$('input').bind('focus', false);
});Run Code Online (Sandbox Code Playgroud)
body {
margin: 20px;
}
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
.prdin {
text-align: center;
background: #f5f5f5;
width: 40px;
border: 1px solid #ccc;
border-top: 0px;
margin: 20px;
}
.prdin div {
display: flex;
height: 37px;
justify-content: center;
align-items: center;
border-top: …Run Code Online (Sandbox Code Playgroud)给定我有一个数字数组,例如[14,6,10]-如何找到可以加和到给定目标值的可能组合/对。
例如我有[14,6,10],我正在寻找40的目标值, 我的预期输出将是
10 + 10 + 6 + 14
14 + 14 + 6 + 6
10 + 10 + 10 + 10
Run Code Online (Sandbox Code Playgroud)
*顺序不重要
话虽如此,这是我到目前为止尝试过的:
function Sum(numbers, target, partial) {
var s, n, remaining;
partial = partial || [];
s = partial.reduce(function (a, b) {
return a + b;
}, 0);
if (s === target) {
console.log("%s", partial.join("+"))
}
for (var i = 0; i < numbers.length; i++) {
n = numbers[i];
remaining = numbers.slice(i …Run Code Online (Sandbox Code Playgroud)