我想在VSCode中缩进代码的特定部分
我读了如何在Visual Studio Code(VSCode)帖子中格式化代码,该代码提供了缩进整个代码的快捷方式,但在选择特定代码段时它不起作用.
我ctrl+shift+F在我的代码中选择了一些行后尝试了但是整个文件都是缩进的.我在Windows上使用VSCode Insider 1.8.0.任何帮助表示赞赏.
如何导出无状态纯哑组件?
如果我使用类,这有效:
import React, { Component } from 'react';
export default class Header extends Component {
render(){
return <pre>Header</pre>
}
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我使用纯函数,我无法使其工作.
import React, { Component } from 'react';
export default const Header = () => {
return <pre>Header</pre>
}
Run Code Online (Sandbox Code Playgroud)
我错过了什么基本的东西?
如何使用Visual Studio代码根据babel/ES7 stage-0规则lint JavaScript文件?
我只需要lint代码.我已经有webpack转换Js文件了.
我需要gulp start使用VScode 调试一个命令(我在翻译过程中遇到了一些与babel有关的映射错误,我还不明白......).VSCode调试默认配置旨在启动node app.js.如何修改它来触发gulp command?
这是默认配置.如果有人暗示我怎么能这样做,我将负债:)
{
"version": "0.2.0",
"configurations": [
{
"name": "Lancer",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/app.js",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
"preLaunchTask": null,
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"externalConsole": false,
"sourceMaps": false,
"outDir": null
},
{
"name": "Attacher",
"type": "node",
"request": "attach",
"port": 5858,
"address": "localhost",
"restart": false,
"sourceMaps": false,
"outDir": null,
"localRoot": "${workspaceRoot}",
"remoteRoot": null
}
]
}
Run Code Online (Sandbox Code Playgroud) 我搜索了一个包来自动缩进和美化我的React/babel代码.我刚试过原子美化,似乎在Atom上有很好的反馈.
但是通常的babel文件的结果还不够好:"HTML标签"不会按需要缩进.有没有人试图用babel原子美化?
我是ImmutableJS的新手.我的应用程序实现了大型Redux Store和多个反应组件.
如我错了请纠正我:
shouldComponentUpdate()必须实现.这个功能的最佳实现是什么?
我已经找到了它的几个实现,都使用了shallowEqual()并进行了一些修改:
is()功能被ImmutableJS给出的功能所取代.第一个平等也是不同的.有人知道我应该在我的案例中使用哪种实现方式?或者没有具体实施shouldComponentUpdate()?我在这一点上略有不知所措
非常感谢你的帮助!!
我曾经用多个配置编写组件例如:
ResponsiveTable.PropTypes = {
width: React.PropTypes.number, //used if widthOffset and minWidth are undefined
widthOffset: React.PropTypes.number, //used if width is undefined
minWidth: React.PropTypes.number, //used if width is undefined
};
Run Code Online (Sandbox Code Playgroud)
我怎样才能声明只有在我已经设置了其他道具的情况下才能使用的道具?
一个XOR选项是有用的.我阅读https://facebook.github.io/react/docs/reusable-components.html但它没有帮助.
有任何想法吗?
我有一个 UTF-8 编码的文件。
我编写了一个 groovy 脚本来加载具有 JSON 结构的文件,对其进行修改并保存:
def originPreviewFilePath = "./xxx.json"
//target the file
def originFile = new File(originPreviewFilePath)
//load the UTF8 data file as a JSON structure
def originPreview = new JsonSlurper().parse(originFile,'UTF-8')
//Here is my own code to modify originPreview
//Convert the structure to JSON Text
def resultPreviewJson = JsonOutput.toJson(originPreview)
//Beautify JSON Text (Indent)
def finalFileData = JsonOutput.prettyPrint(resultPreviewJson)
//save the JSONText
new File(resultPreviewFilePath).write(finalFileData, 'UTF-8')
Run Code Online (Sandbox Code Playgroud)
问题是JsonOutput.toJson将 UTF-8 数据转换为 UNICODE。我不明白为什么JsonSlurper().parse可以使用 UTF-8 而不是JsonOutput.toJson?
如何JsonOutput.toJson …
我知道我的问题标题看起来很奇怪,但我不知道怎么问这样的问题.
我有两个 arrays
a = [1,2,3]
Run Code Online (Sandbox Code Playgroud)
和
b = ["gf","gdf","gdf"]
Run Code Online (Sandbox Code Playgroud)
我有一个这样的return语句:
return {
options: a.map(value => ({ label: value, value: value }))
};
Run Code Online (Sandbox Code Playgroud)
但我希望选项内部的值取b数组的值而不是a数组的值.这该怎么做?
我正在使用Visual Studio代码来开发nodeJS应用,并且已经具有eslint配置来对未声明的变量进行初始化。
但是在最新的VSCode版本中,不再删除一些未声明的变量。喜欢event,name,crypto,...
当达到变量定义时,它实际上是在文件中声明的 Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\lib.dom.d.ts
我看不出为什么要为nodeJS应用程序全局声明这些变量的任何原因。如何禁用这些变量的全局定义?
reactjs ×4
javascript ×3
ecmascript-6 ×2
arrays ×1
atom-editor ×1
babel ×1
babeljs ×1
debugging ×1
ecmascript-7 ×1
encoding ×1
eslint ×1
export ×1
groovy ×1
gulp ×1
immutable.js ×1
indentation ×1
json ×1
node.js ×1
prettify ×1
redux ×1
unicode ×1
utf-8 ×1