如何在dart中调用jquery's $函数 [英] How to call jquery´s $ function in dart
问题描述
我尝试在dart中创建以下jquery函数调用
I try to make the following jquery functioncall in dart
$('#mytable').handsontable({
data: data,
minSpareRows: 1,
colHeaders: true,
contextMenu: true
});
我的dartcode
my dartcode
import 'dart:js';
void main()
{ var data = [["", "Maserati", "Mazda", "Mercedes", "Mini", "Mitsubishi"],
["2009", 0, 2941, 4303, 354, 5814] ];
context.callMethod('$', ['#mytable'])
.callMethod('handsontable', [new JsObject.jsify(
{'data': data,
'minSpareRows': 1,
'colHeaders': true,
'contextMenu': true})]);
}
行:
context.callMethod('$', ['#mytable'])
在编辑器中产生一个错误:期望一个标识符('$'标记为红色)
任何其他字符串,然后'$'semes是确定的,但$() p>
produces an error in the editor: Expected an identifier ('$' is marked red) Any other string then the '$' semes to be ok, but the jquery function in $()
推荐答案
得到错误,因为 $
是Dart字符串中要执行的字符字符串插值。要使你的代码工作,你必须转义这个字符 context.callMethod('\ $',['#mytable'])
或使用原始字符串 context.callMethod(r'$',['#mytable'])
。
You get the error because $
is the character in Dart String to perform String interpolation. To make your code work you have to escape this character context.callMethod('\$', ['#mytable'])
or use a raw String context.callMethod(r'$', ['#mytable'])
.
这篇关于如何在dart中调用jquery's $函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!