我試圖使圖像查看器顯示圖像標籤,並且我打算使用重複模板輸出標籤。不幸的是我得到這個錯誤時不支持的操作:無法評估'in'表達式
Breaking on exception: Unsupported operation: can't eval an 'in' expression
通過向上移動堆棧跟蹤我能夠確定的是,表達被評價爲「在標記列表爲tag_string」,它來源於此自定義元素:
<link rel="import" href="packages/polymer/polymer.html">
<polymer-element name="dartlery-viewer">
<template>
<style>
:host {
position:absolute;
left:210px;
top:0px;
border: solid 0px black;
right:0;
text-align:center;
}
div#viewer {
display:none;
}
</style>
<div id="viewer">
<img src="{{imageSource}}" />
<textarea>
<template repeat="{{tag_string in tagList}}">
tag
</template>
</textarea>
</div>
</template>
<script type="application/dart" src="dartlery_viewer.dart"></script>
</polymer-element>
這是它的類:
import 'dart:html';
import 'dart:convert';
import 'package:polymer/polymer.dart';
import 'package:dartlery_client/dartlery.dart';
@CustomTag('dartlery-viewer')
class DartleryViewerElement extends PolymerElement {
@observable String id = "-1";
@observable String imageSource = "-1";
final List tagList = new ObservableList();
Element get _ele {
return $["viewer"];
}
DartleryViewerElement.created() : super.created() {
}
void displayFile(String id) {
HttpRequest.getString("${SERVER_ADDRESS}files/${id}").then((response) {
Map data = JSON.decode(response);
if(data["files"]!=null) {
for(Map file in data["files"]) {
_showImageData(file);
}
}
});
this.show();
this.id = id;
}
void _showImageData(Map data) {
this.tagList.clear();
this.tagList.addAll(data["tags"]);
this.imageSource = data["src"];
}
void hide() {
this._ele.style.display = "none";
}
void show() {
this._ele.style.display = "block";
}
}
我錯過了什麼愚蠢的?
服務器的響應是什麼?你能打印嗎? – Vink
一些JSON廢話,但這是一個有爭議的問題,岡特有答案。 – SanMadJack