का उपयोग कर गतिशील रूप से एक डार्ट स्क्रिप्ट लोड करें मैं डार्ट का उपयोग करके गतिशील रूप से एक डार्ट स्क्रिप्ट लोड करने का प्रयास कर रहा हूं। मैं कुछ इस तरह उपयोग कर रहा हूँ:डार्ट
test.html:
...
<script src="http://dart.googlecode.com/svn/branches/bleeding_edge/dart/client/dart.js"></script>
<script type="application/dart" src="test.dart"></script>
...
test.dart:
#import('dart:html');
main() {
var script = new ScriptElement();
script.type = 'application/dart';
script.src = 'helloworld.dart';
document.body.elements.add(script);
}
यह काम नहीं करता। हालांकि, अगर मैं HTML फ़ाइल में एक ही कोड इनलाइन, यह ठीक काम करता है:
test.html:
...
<script src="http://dart.googlecode.com/svn/branches/bleeding_edge/dart/client/dart.js"></script>
<script type="application/dart">
#import('dart:html');
main() {
var script = new ScriptElement();
script.type = 'application/dart';
script.src = 'helloworld.dart';
document.body.elements.add(script);
}
</script>
...
हो रहा क्यों है?
यह एक बग की तरह दिखता है। शायद आपको [डार्टबग] (http://www.dartbug.com) पर एक समस्या जोड़नी चाहिए –
मैं सहमत हूं। वर्तमान में डार्ट स्क्रिप्ट एलिमेंट() के माध्यम से लोड करने योग्य नहीं होना चाहिए (यह जावास्क्रिप्ट लोड करना है और यहां तक कि इंटर-संचार हवा में बहुत अधिक है)। वर्तमान में डार्ट कोड लोड करने का प्राथमिक तरीका Isolate.spawnURI() –
@MattB के साथ है: मैंने देखा कि डार्ट कोड इनलाइन करना संभव है: http://www.dartlang.org/articles/embedding-in-html/ और यह काम करता है ! –