我有以下型号:
Specs
trait Specs {
def name: String
}
case class SportsCarSpecs(name: String, details: Details) extends Specs
是一种特质,具有以下具体类型:
@dom
def buildTable(): Binding[BindingSeq[Node]] = {
val data = Vars.empty[CarBinding]
/* Initial population. */
// Some code...
<br/>
<table class="table table-bordered table-hover">
<thead>
<tr>
<th class="col-md-1">
<small>Owner ID</small>
</th>
<th class="col-md-1">
<small>Specs</small>
</th>
</tr>
</thead>
<tbody>
{for (entry <- data) yield {
<tr>
<td>
<small>
{entry.ownerId.bind}
</small>
</td>
<td>
<small>
{entry.specs.bind match {
case Some(SportsCarSpecs(name, details)) => {name} <span>{details.ps}</span>
case _ => -
}}
</small>
</td>
</tr>
}}
</tbody>
</table>
</div>
}
在我的Scala.js应用程序中,我现在想要创建一个表并列出所有条目:
';' expected but $XMLSTART$< found.
[error] case Some(SportsCarSpecs(name, details)) => {name} <span>{details.ps}</span>
但是,我收到以下错误:
let enabled = false;
class List {
constructor (...args) {
this.args = args;
}
get Count() {
if (enabled) {
let _this = this;
return () => _this.args.length;
}
return this.args.length;
}
}
let list = new List('a', true, null);
// 'Count' is not a method/function by default
console.log(list.Count); // 3
// do something to enable this flag:
enabled = true;
// 'Count' is a method now
console.log(list.Count()); // 3
我做错了什么?
答案 0 :(得分:3)
此:
entry.specs.bind match {
case Some(SportsCarSpecs(name, details)) => {name} <span>{details.ps}</span>
case _ => -
}
不是有效的表达式,因此您无法在XML文本中插入它。如果你在两个分支中都有完整的XML表达式,它应该可以工作。因此,我能看到的最简单的解决方法是将<small>
拉入内部:
<td>
{entry.specs.bind match {
case Some(SportsCarSpecs(name, details)) => <small>{name} <span>{details.ps}</span></small>
case _ => <small>-</small>
}}
</td>