2020年3月25日 星期三
從 dart 呼叫 javascript
參考官網文章: http://dartdoc.takyam.com/articles/js-dart-interop/
// index.html
<html><head><meta charset='utf-8'></head><body>
<script type='application/javascript' src='hello.js'></script>
<script type='application/javascript' src='main.js'></script>
</body></html>
// hello.js
var greeting="Hello"; // 1. variable
function fun( ){ //2. function
console.log("How are you?");
}
class Rectangle {
constructor(width, height) {
this.width = width;
this.height = height;
}
}
function rectangle(width, height) { // 3. object
return new Rectangle(width, height); // return an object
}
// main.dart
import 'dart:js';
void main() {
var greeting = context['greeting']; // 1.
print("$greeting");
context.callMethod('fun'); //2.
final rectangle = JsObject(context['rectangle'], [5, 1]); //3.
print(rectangle['width']);
}
訂閱:
張貼留言 (Atom)
使用 pcie 轉接器連接 nvme SSD
之前 AM4 主機板使用 pcie ssd, 但主機板故障了沒辦法上網, 只好翻出以前買的 FM2 舊主機板, 想辦法讓老主機復活, 但舊主機板沒有 nvme 的界面, 因此上網買了 pcie 轉接器用來連接 nvme ssd, 遺憾的是 grub2 bootloader 無法識...
-
市面上便宜的時鐘, 內部機芯大多使用晶體振盪器產生固定頻率的脈沖去驅動 Lavet-type 步進馬達, 它只要一個 1.5V 電池就足以推動, 而馬達扭力主要是靠線圈內的電流產生磁力所致, 因此電流才是動力來源. 電壓太高會造成線圈電流飽和導致發熱,可能影響震盪頻率甚至燒毀...
-
參考資料: https://developer.android.com/training/connect-devices-wirelessly/nsd linux mint 上針對區域網路的名稱服務協定可以使用 avahi, 透過 avahi-browse -a -r 就能...
沒有留言:
張貼留言