如何永久启用Sublime Text 3 LiveReload插件(How to permanently enable Sublime Text 3 LiveReload plugin)
我最近为Sublime Text 3安装了LiveReload 插件 。我还安装了LiveReload Chrome扩展程序。 一切都很好,但仍然有一个头痛。 我需要在Sublime中进行包控制,并在每次打开Sublime时启用LiveReload Simple Reload插件。 有没有办法永久启用Sublime Text 3 LiveReload插件?
I recently installed the LiveReload plugin for Sublime Text 3. I also installed the LiveReload Chrome extension. Everything works great, however there's one remaining headache. I need to go into package control in Sublime and enable the LiveReload Simple Reload plugin every time I open Sublime. Is there a way to permanently enable Sublime Text 3 LiveReload plugins?
原文:https://stackoverflow.com/questions/25597590
最满意答案
用括号括起来,就像这样
getInitialState: () => ({ text: this.props.text })
如果没有括号,对象文字看起来也像一个带有名为
text
的标签的JavaScript块。 由于它不明确,因此抛出SyntaxError。 但当你用()
包围它时,JavaScript知道它是一个Object文字。
我认为现在这个箭头功能受到限制
箭头功能没有
this
。 当在箭头函数中遇到this
情况时,它将转到上一级以查看this
是否在那里可用并使用它。 你可以像这样确认一下(function Test1() { console.log(this); (() => console.log(this))(); }).bind({a: 1})();
会打印
{ a: 1 } { a: 1 }
在您的情况下,
this
将引用声明它的函数的this
对象,而不是对象本身。Surround it with parenthesis, like this
getInitialState: () => ({ text: this.props.text })
without the parenthesis, the object literal looks also like a JavaScript block with a label called
text
in it. Since it is ambiguous, the SyntaxError is thrown. But when you surround it with()
, JavaScript knows that it is an Object literal.
I think this is being bound now to that arrow function
Arrow functions don't have
this
. Whenthis
is encountered in an arrow function, it will go to previous level to see ifthis
is available there and use that. You can confirm that, like this(function Test1() { console.log(this); (() => console.log(this))(); }).bind({a: 1})();
would print
{ a: 1 } { a: 1 }
In your case,
this
will refer thethis
object of the function in which it is declared, not the object itself.
相关问答
更多-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
ES6胖箭头和圆括号`(...)=>({...})``[duplicate](ES6 Fat Arrow and Parentheses `(…) => ({…})` [duplicate])[2023-01-26]
fields: () => ({ field: {/*etc.*/} }) 是一个隐式返回对象(文字)的函数。 如果不使用() JavaScript解释器会将{}作为函数体的包装器而不是对象。 不使用parens:( () , field: ...语句被视为label语句,函数返回undefined 。 等效的语法是: fields: () => { // start of the function body // now we have to define an object // a ... -
您正在错误地查看代码。 总体结构是 private Name: Type = Value 类型为(page: string) => void ,值为(page) => {} 。 该类型意味着navigateTo是一个接受字符串作为参数并且不返回任何内容的函数,这就是(page) => {}所做的。 You are looking at the code incorrectly. The general structure is private Name: Type = Value The type is ...
-
是的,通过使用简洁的箭头形式,将对象初始值设定项封装在() : elements.map(element => ({...element, selected: false})); // ---------------------^-----------------------------^ 你需要()因为否则{对象初始值设定项被读为{作为函数体的开始。 (而是使其成为隐含return的表达主体。 Yes, by using the concise arrow form, enclosing the obj ...
-
与对象的胖箭头(fat arrow with objects)[2022-07-12]
有几种方法可以做到这一点: Object.keys(test).forEach(key => console.log(test[key])); Object.keys是最古老的方法,自ES5起可用。 但是,当您使用ES6方法时,您可以使用更新的方法: Object.keys(test) // ['a', 'b', 'c', 'd'] Object.values(test) // [1, 2, 3, 4] Object.entries(test) // [['a', 1], ['b', 2], ['c', ... -
我不认为有什么方法可以用'pure'js语法来做你想要的。 如果你想避免重复和保持可读性,创建自己的映射函数工厂似乎是最好的解决方案。 function fromState(...props) { return state => { const importedState = {}; props.forEach(prop => importedState[prop] = state[prop]); return importedState; } } 然后你可以像这样在连接中 ...
-
我假设sortGroup是指数据上的一个属性的名称,在这种情况下,我认为你需要更像这样的东西: const data = [{ campaign: "Charles", company_ID: "1", coreURL: "http://www.test77.com", createdAt: "2017-11-06T20:45:56.931Z", owner: "K7xTxu7PRDCuhFZRC", updatedAt: "2017-09-06T20:45:56.931 ...
-
箭头函数将词法绑定应用于this关键字,有效地使其成为一个常量,等于在评估箭头函数时在外部作用域上相等的值。 甚至不使用function.call() , function.apply()或function.bind()都可以覆盖该值。 您应该告知其定义的任何人,并强制执行样式指南,使其规则被破坏,并且在实际场景中无法遵循。 此外,箭头功能不能取代“标准”功能,它们添加了新的语言功能。 An arrow function applies lexical binding to the this keyword ...
-
用括号括起来,就像这样 getInitialState: () => ({ text: this.props.text }) 如果没有括号,对象文字看起来也像一个带有名为text的标签的JavaScript块。 由于它不明确,因此抛出SyntaxError。 但当你用()包围它时,JavaScript知道它是一个Object文字。 我认为现在这个箭头功能受到限制 箭头功能没有this 。 当在箭头函数中遇到this情况时,它将转到上一级以查看this是否在那里可用并使用它。 你可以像这样确认一下 ...
-
为什么类方法中的胖箭头没有绑定到父范围呢?(Why is the fat arrow in a class method not binding to the parent scope's this?)[2022-02-07]
你在这里滥用bind 。 let category = callback(mapping[key]).bind(this); bind创建一个函数的副本,使用this set设置为传递它的任何内容以及预加载的零个或多个参数。 function log(argument1) { console.log(this); console.log(argument1); } let f = log.bind({ a: 1 }, 'a'); let g = log.bind({ b: 2 }, ...