我正在尝试升级到最新版本的节点.我按照http://davidwalsh.name/upgrade-nodejs上的说明进行操作
但当我这样做时:
sudo npm install -g n
Run Code Online (Sandbox Code Playgroud)
我收到错误:
sudo: npm: command not found
Run Code Online (Sandbox Code Playgroud)
npm没有sudo.当我做:
whereis node
Run Code Online (Sandbox Code Playgroud)
我知道了:
node: /usr/bin/node /usr/lib/node /usr/bin/X11/node /usr/local/node
Run Code Online (Sandbox Code Playgroud)
运行:
which npm
Run Code Online (Sandbox Code Playgroud)
显示:
/usr/local/node/bin/npm
Run Code Online (Sandbox Code Playgroud)
我在/sf/answers/354390291/上尝试了该解决方案
但我仍然得到同样的错误.我还查看了/ etc/sudoers文件,相关的行是:
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Run Code Online (Sandbox Code Playgroud)
这看起来很好.我怎样才能让NPM使用sudo命令?
将函数绑定到按钮非常简单直接:
<button on:click={handleClick}>
Clicks are handled by the handleClick function!
</button>
Run Code Online (Sandbox Code Playgroud)
但是当我这样做时,我没有看到将参数(参数)传递给函数的方法:
<button on:click={handleClick("parameter1")}>
Oh no!
</button>
Run Code Online (Sandbox Code Playgroud)
该函数在页面加载时被调用,并且永远不会再次调用。
是否有可能将参数传递给从 调用的函数on:click{}?
我刚刚找到了一个hacky的方法来做到这一点。从内联处理程序调用该函数有效。
<button on:click={() => handleClick("parameter1")}>
It works...
</button>
Run Code Online (Sandbox Code Playgroud) 我有两个包含mocha测试用例的javascript文件.
//----------abc.js -------------
describe("abc file", function(){
it("test 1" , function(){
assert.equal(20 , 20);
});
});
//---------xyz.js--------------
describe("xyz file", function(){
it("test 1" , function(){
assert.equal(10 , 10);
});
});
Run Code Online (Sandbox Code Playgroud)
我把它们放在一个名为的文件夹中test,当我执行mocha命令时,第一个文件(abc.js)总是在xyz.js之前执行.我认为这可能是由于按字母顺序排列并将文件重命名为
abc.js => xyz.js
xyz.js => abc.js
Run Code Online (Sandbox Code Playgroud)
但是,仍然首先执行xyz.js(先前的abc.js)的内容.如何更改这些测试文件的执行顺序?
我已经有了答案:
const faunadb = require('faunadb')
const q = faunadb.query
exports.handler = async (event, context) => {
const client = new faunadb.Client({
secret: process.env.FAUNADB_SERVER_SECRET
})
try {
// Getting the refs with a first query
let refs = await client.query(q.Paginate(q.Match(q.Index('skus'))))
// Forging a second query with the retrieved refs
const bigQuery = refs.data.map((ref) => q.Get(ref))
// Sending over that second query
let allDocuments = await client.query(bigQuery)
// All my documents are here!
console.log('@allDocuments: ', allDocuments);
//...
} catch (err) {
// …Run Code Online (Sandbox Code Playgroud) 我得到了MAJOR.MINOR.PATCH的逻辑,并在直觉上得到了-alpha和-beta在semver数字末尾的含义,但是-rc对我来说没有任何响声。
在那里找不到令人满意的答案-> https://semver.org/
这是我指的 API: https: //developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API
至于到目前为止我所尝试过的:
Modernizr 有这个Modernizr.fullscreen东西,但我不想使用另一个库来完成看似简单的任务。
所以我正在挖掘 Modernizr 的源代码来尝试看看他们是如何做到这一点的,毕竟 Modernizr 确实使用 JS 来解决它,对吧?但到目前为止,我在源代码中发现的有关全屏 API 的就是这个文件(Modernizr/feature-detects/fullscreen-api.js)
/*!
{
"name": "Fullscreen API",
"property": "fullscreen",
"caniuse": "fullscreen",
"notes": [{
"name": "MDN Docs",
"href": "https://developer.mozilla.org/en/API/Fullscreen"
}],
"polyfills": ["screenfulljs"],
"builderAliases": ["fullscreen_api"]
}
!*/
/* DOC
Detects support for the ability to make the current website take over the user's entire screen
*/
define(['Modernizr', 'prefixed'], function(Modernizr, prefixed) {
// github.com/Modernizr/Modernizr/issues/739
Modernizr.addTest('fullscreen', !!(prefixed('exitFullscreen', document, false) || prefixed('cancelFullScreen', document, false)));
});
Run Code Online (Sandbox Code Playgroud)
...我不太明白该代码。然而。
我正在尝试使用以下API下载针对Android Apps的评论。 https://developers.google.com/android-publisher/api-ref/reviews
但这需要身份验证。因此,我按照上面链接中链接的说明进行操作。
我能够获得访问令牌。
但是我得到以下回应:
{
"error": {
"errors": [
{
"domain": "androidpublisher",
"reason": "projectNotLinked",
"message": "The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console."
}
],
"code": 403,
"message": "The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console."
}
}
Run Code Online (Sandbox Code Playgroud)
我看到其他一些帖子说,您必须将其与Google Play开发者控制台关联。所以我做到了(见下图)。
[
]
但是我仍然收到此错误。请帮忙。
google-api google-api-client google-console-developer google-play-developer-api google-developers-console
当我在 VS Code 中使用“转到文件...”功能(在 mac 上为command+ P)时,VS Code 会列出该/var/folders/...路径下的文件。
选择下面的文件之一/var/folders/通常会产生“无法打开编辑器,因为找不到文件。”。
我很确定这些是 Git 使用的临时文件。当我使用 git 历史功能时,下面的文件var/folders/显示为“最近打开”;将文件与其自身的先前版本进行比较。
有没有办法设置 VS Code 以便只显示当前工作目录中的文件?
为了在递归迭代JSON对象时创建条件,我试图找到一种区分不同对象类型的简洁方法.
考虑一下:
var aJSON = {"foo" : 1, "bar" : 2};
var anArray = [1,2,3,4,5];
var aDate = new Date('2013-03-10T02:00:00Z');
var anISODate = user.timesTheyLoggedIn[0] // comes from MongoDB
console.log(typeof aJSON); // object
console.log(typeof anArray); // object
console.log(typeof aDate); // object
console.log(typeof anISODate); // object
Run Code Online (Sandbox Code Playgroud)
所有类型的对象都是"对象",没有更多信息.
现在,我的用例只需要检测一个ISODate对象,所以我利用具有resetTime函数的ISODate对象将它们与其他对象区分开来,如下所示:
if (typeof(val) === "object" && val.resetTime === undefined) { //do stuff...
Run Code Online (Sandbox Code Playgroud)
但是必须有一种更清洁,更好的方法来检测物体是什么类型的物体,val.isArray()有点像......
怎么会这样?
PS:"不同的对象类型"在引号中,因为JS中只有一个对象类型,对吧?
我正在使用 Chakra ui。
我想将按钮颜色更改为#2477b3。我可以通过传递props中的值来改变它,但是每次传递props中的值需要花费很多时间和精力,所以我想改变默认的Button颜色等,
我想使用的样式A 按钮。
我更改了theme.ts并创建了BButton,但样式没有改变。我尝试更改 theme.ts 中的值,但颜色没有改变。
<Button
size={'sm'}
bg="#2B6CB0"
_hover={{ bg: '#2477b3' }}
_active={{
bg: '#2477b3',
transform: 'scale(0.98)',
borderColor: '#2477b3',
}}
color={'#ffffff'}
>
AButton
</Button>
<Button>BButton</Button>
Run Code Online (Sandbox Code Playgroud)
主题.ts
import { extendTheme } from '@chakra-ui/react';
export const theme = extendTheme({
components: {
Button: {
baseStyle: {
fontWeight: 'bold',
_hover: {
_disabled: {
bg: '#2477b3',
},
},
},
variants: {
bg: '#2B6CB0',
_active: {
bg: '#2477b3',
transform: 'scale(0.98)',
borderColor: '#2477b3',
},
},
},
},
});
Run Code Online (Sandbox Code Playgroud)