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)
使用 python 簡單實現多 cpu 平行處理
import multiprocessing as mp import time def iso_task(k): print(f"task {k} @{time.time()} sec: sleep for 1 second") time....
-
1. 目前使用 linux mint 22.1 作業系統可以順利跑起來, 可上官網去下載, 並安裝到硬碟. 2. 安裝 waydroid 可上網站 https://docs.waydro.id 參考看看: https://docs.waydro.id/usage/inst...
-
if { } else { } 是流程進行的分歧點, 當層級過多時, 程式碼的邏輯就變的難以理解, 例如像是: if(... ) { if(... ) { if(... ) { ...
沒有留言:
張貼留言