我最近从Ionic 2升级到了Ionic 3,我创建了components.module.ts文件并声明并导出了我拥有的每个自定义组件,然后在我拥有的每个页面模块中导入了这个单个文件.
所以现在问题是我不能在我自己的组件中使用ion-*组件,因为我没有导入IonicModule.forRoot(..)我的components.module里面.
错误是:
"模板解析错误:'ion-spinner'不是已知元素......"
我究竟做错了什么?
我想知道 - 我看到了捆绑客户端代码的好处,但是使用 Browserify/Webpack 捆绑服务器端代码是否被认为是好的做法?
当运行在铬合金性能选项卡JS脚本,我看到有三个步骤JS解释:Parse,Compile和Evaluate。有时候,我只是看Evaluate,有时Compile和Evaluate有时它的整机三年。
我的问题是:
Parse会丢失)以下代码调用console.log打印"hello":
console.log.call(console, "hello")
Run Code Online (Sandbox Code Playgroud)
但是,下面的代码抛出TypeError:
x = console.log.call
x(console, "hello")
Run Code Online (Sandbox Code Playgroud)
抛出:
Uncaught TypeError: x is not a function
at <anonymous>:1:1
Run Code Online (Sandbox Code Playgroud)
谁能解释这个奇怪的场景?
(当然,这是相同的两个call和apply)
当客户端向数据库添加内容时,我使用 Firebase 的云函数来执行触发器,但这些触发器似乎需要很长时间才能执行。
例如,我有一个触发器,每当将帖子添加到数据库时,它就会向帖子添加创建日期,大约需要 10 秒才能完成。另外,我有更大的触发器,需要更长的时间。
我是否缺少“最佳实践”?我做错了什么吗?
我遇到了以下基准:https://jsperf.com/array-includes-and-find-methods-vs-set-has \n如果你执行它,你会发现这map.has是迄今为止最在浏览器中查找集合中的项目的有效方法。
我还在 Node 中使用重新创建了这个测试benchmarks.js,并得到了以下结果:
节点9.4.0:
\n\nset.has x 6,454,428 ops/sec \xc2\xb11.25% (90 runs sampled)\nmap.has x 64,519,657 ops/sec \xc2\xb10.95% (86 runs sampled)\narr.includes x 11,415,721 ops/sec \xc2\xb11.41% (87 runs sampled)\narr.indexOf x 11,344,587 ops/sec \xc2\xb11.39% (87 runs sampled)\narr.find x 1,579,635 ops/sec \xc2\xb11.09% (92 runs sampled)\nFastest is map.has\nRun Code Online (Sandbox Code Playgroud)\n\n节点6.2.0:
\n\nset.has x 16,677,473 ops/sec \xc2\xb11.35% (86 runs sampled)\nmap.has x 15,089,503 ops/sec \xc2\xb11.35% (85 runs sampled)\narr.includes x 1,345,019 ops/sec \xc2\xb11.31% (89 runs sampled)\narr.indexOf x 15,943,213 ops/sec …Run Code Online (Sandbox Code Playgroud) 我知道您可以使用模板文字来提供方法的第一个参数,例如:
const f = x => "hello ," + x;
f`world` // returns 'hello, world'
Run Code Online (Sandbox Code Playgroud)
所以我可以以某种方式理解为什么这段代码有效:
String.raw`bla bla`
Run Code Online (Sandbox Code Playgroud)
但是,我似乎无法理解为什么带括号的相同方法调用会引发错误:
String.raw(`bla bla`)
Run Code Online (Sandbox Code Playgroud)
抛出: Uncaught TypeError: Cannot convert undefined or null to object
我的问题是:
为什么第一个片段有效?为什么我可以在方法调用中用模板文字替换括号?
为什么String.raw只有在以这种方式调用时才有效?
javascript ×5
angular ×1
benchmarking ×1
browserify ×1
devtools ×1
ecmascript-6 ×1
firebase ×1
ionic2 ×1
ionic3 ×1
node.js ×1
performance ×1
typescript ×1
v8 ×1
webpack ×1