我正在使用MS SQL.
我有以下表格:
table A:
id1 data1
8234 ko
2 po
333 koo
40 woo
table B:
id2 data2
123 meow
654 frrr
table C:
id3 data3
10 a
20 b
30 c
40 d
50 e
60 f
Run Code Online (Sandbox Code Playgroud)
我想得到这个:
id1 data1 id2 data2 id3 data3
8234 ko 123 meow 10 a
2 po 654 frrr 20 b
333 koo NULL NULL 30 c
40 woo NULL NULL 40 d
NULL NULL NULL NULL 50 e
NULL NULL NULL NULL …Run Code Online (Sandbox Code Playgroud) 今天,我的WebStorm开始表现得很奇怪.当我在断点处停止时 - 进程下降.它发生在任何断点处.我使用nodejs javascript.
我试着记录gif,但是质量非常糟糕(对不起),但是,如果你看一下gif,你可以想象出这个问题.

正如你在这里看到的那样:调试器捕获了一个断点,但是,进程刚刚停止.在webstorm的底部写着:"处理完成后退出代码-1073741510(0xC000013A:被Ctrl + C中断)".
昨天一切都很完美,有什么不对吗?
我想描述一些带有嵌套对象的接口。不为嵌套对象创建接口怎么办?
interface ISome {
strProp:string;
complexProp:{
someStrKeyWhichIsDynamic:{
value:string;
optValue?:string;
}
};
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过(UPD:实际上还可以)
interface ISome {
strProp:string;
complexProp:{
[someStrKeyWhichIsDynamic:string]:{
value:string;
optValue?:string;
}
};
}
Run Code Online (Sandbox Code Playgroud)
但是我不能分配一个像
let dynamicStrKey = 'myKey';
{
strProp:'str',
complexProp:{
[dynamicStrKey]:{
value:'something here',
optValue: 'ok, that too',
}
};
Run Code Online (Sandbox Code Playgroud)
转换为ISome没有类型断言的类型的变量<ISome>。至少WebStorm将此任务突出显示为错误。
如何正确描述嵌套对象?
例子:
基础类型:
/**
* @typedef {Object} LabelValue
* @template T
* @property {String} label
* @property {T} value
*/
Run Code Online (Sandbox Code Playgroud)
可以很好地用作
/** @type {LabelValue<SomeType>} */
我想像这样扩展这个基本类型(也许这只是错误的语法,我不确定):
/**
* @typedef {LabelValue<T>} LabelValueExtended
* @template T
* @property {String} extensionProp
*/
Run Code Online (Sandbox Code Playgroud)
我使用 webstorm 并且它没有根据这样使用的类型向我显示任何建议:
/** @type {LabelValueExtended<SomeType>} */
此变体也不会触发来自 webstorm 的任何建议:
/**
* @typedef {LabelValue} LabelValueExtended
* @template T
* @property {String} label
* @property {T} value
* @property {String} extensionProp
*/
Run Code Online (Sandbox Code Playgroud)
但只有当我用Object模板之类的常见类型替换我的自定义类型时才能正常工作。例如这有效:
/**
* @typedef {Object} LabelValueExtended
* @template T …Run Code Online (Sandbox Code Playgroud) var myArray = [];
myArray = document.querySelectorAll('.selected');
Run Code Online (Sandbox Code Playgroud)
当我打电话给myArray.splice时 - 它是未定义的.我怎么能避免这个?我需要从该数组中删除一些DOM元素.
我检查这个关于另一个作者git commit下的提交的问题,作为不同的用户,没有电子邮件/或只有电子邮件
我怎么能在另一个登录下推送到远程仓库.我做:
git commit --author="notMe" -m "whatever"
git push https://<remote-repo>
Username for 'https://github.com': notMe
Password for 'https://qRoman@github.com': <notMe's password>
Run Code Online (Sandbox Code Playgroud)
但结果我得到了这个:
我怎样才能像其他作者那样提交和推送?
UPD:我试过git config user.name "notMe",结果是:

这几乎是我想要的,但为什么我的头像还在这里?
在启动服务器之前,我需要导出('设置'实际,我使用的是Win7)NODE_PATH变量.我尝试使用此命令(即使在命令行中也不工作):
set NODE_PATH=./ && node server.js
Run Code Online (Sandbox Code Playgroud)
并为package.json:
"scripts": {
"start": "set NODE_PATH=. && node server.js"
},
Run Code Online (Sandbox Code Playgroud)
但它不起作用.我得到的Error: Cannot find module只有NODE_PATH未指定才出现.
那么,这个问题怎么解决?我需要一种正确的方法来NODE_PATH使用内联命令导出和运行服务器,或者为"启动"脚本指定两个单独的命令.
如果我在全局注册了一些 vue 组件,我怎样才能让 WebStorm 理解它并帮助我自动完成?我有一些从主 js 文件全局注册的自定义 ui 组件,如下所示:
const requireComponent = require.context(
'./components',
true,
/^\.\/ui-kit\/global\/.*ui-.*\.vue$/
)
requireComponent.keys().forEach(function(fileName) {
let baseComponentConfig = requireComponent(fileName)
baseComponentConfig = baseComponentConfig.default || baseComponentConfig
let baseComponentName =
baseComponentConfig.name ||
fileName.replace(/^.+\//, '').replace(/\.\w+$/, '')
Vue.component(baseComponentName, baseComponentConfig)
})
Run Code Online (Sandbox Code Playgroud)
所以我想使用这样的组件而不需要任何导入。我可以,但唯一的问题是我没有从 WS 识别此类组件。
WebStorm 也将此标签标记为
未知的 html 标签 ui-input
此检查突出显示未知的 HTML 标签,并让将此类标签标记为自定义,以避免将来将它们突出显示为未知
当然,如果我手动导入该组件,WebStorm 的建议就可以正常工作。
假设您有“SFC”,其模板如下:
<template src="./my-separate.html"></template>
<script>/* whatever */</script>
<style>/* whatever */</style>
Run Code Online (Sandbox Code Playgroud)
假设您已经有了 prettier/eslint 设置,并且可以使用以下命令对任何文件进行 lint 检查:
eslint --ext "*.html, *.js, *.vue, *.ts" $FilePath$ --fix --no-ignore
Run Code Online (Sandbox Code Playgroud)
哪种格式的 .vue、.js 甚至 .ts 文件都很好,但是如果你将它用于分离的 vue-template - 这是一个带有 .html 扩展名的文件,但它实际上是带有所有v-ifs 和其他内容的 vue 模板......这不起作用,因为 prettier 可能尝试使用不正确的解析器来解析 .html (?),或者也许应该有一种方法来建议对我棘手的 .html 文件使用哪个解析器?
我当前的配置如下所示:
// .prettier.rc
{
"arrowParens": "always",
"semi": false,
"singleQuote": true
}
// .eslintrc.js
module.exports = {
root: true,
parserOptions: {
parser: 'typescript-eslint-parser',
sourceType: 'module',
jsx: true
},
env: {
browser: true
},
extends: [
'eslint:recommended',
'plugin:prettier/recommended', …Run Code Online (Sandbox Code Playgroud) 我听到这样的意见,你应该避免使用try/catch,因为它需要很多资源.那么可以承诺错误处理可能会更快吗?或者根本没关系?
function f(somethingDangerous) {
return new Promise((resolve, reject) => {
// try {
// somethingDangerous();
// resolve();
// } catch (err) {
// reject(err);
// }
// VS
somethingDangerous();
resolve();
}).catch((err) => {
console.error('Catched: ' + err);
});
}
f(() => {throw 'DANGEROUS THING';});
Run Code Online (Sandbox Code Playgroud)
UPD:我知道try/catch不适用于内部的异步代码.我只是想知道是否有任何理由因为性能问题而避免尝试/捕获?以上两种方法之间有什么区别吗?
UPD2:试图比赛我的马:) https://jsperf.com/try-catch-vs-promise
webstorm ×4
javascript ×3
node.js ×2
vue.js ×2
arrays ×1
command-line ×1
debugging ×1
es6-promise ×1
eslint ×1
git ×1
github ×1
jsdoc ×1
npm ×1
package.json ×1
prettier ×1
promise ×1
shell ×1
sql ×1
sql-server ×1
t-sql ×1
tooling ×1
try-catch ×1
types ×1
typescript ×1