我正在使用以下代码来创建视图:
LoginForm = Backbone.View.extend({
tagName :"form"
,id : "login-form"
,className :"navbar-form"
,initialize: function () {
this.model = new StackMob.User();
this.render();
}
,render: function () {
$(this.el).html(this.template());
return this;
}
,events : {
"change" : "change"
,"submit #login-form" : "login"
}
,login : function( event) {
event.preventDefault();
var self = this;
this.model.login(true, {
success: function( model) {
app.alertSuccess( "User logged in");
self.render();
}
,error: function( model, response) {
app.alertError("Could not login user: " + response.error_description);
}
});
event.currentTarget.checkValidity();
return false;
} …Run Code Online (Sandbox Code Playgroud) 首先,我通过bower包含了stripe.js文件:
bower install --save stripe.js=https://js.stripe.com/v2/
Run Code Online (Sandbox Code Playgroud)
其中创建了"vendor/stripe/index"(注意不是 index.js,而是索引).然后我把它添加到我的西兰花文件中:
app.import('vendor/stripe/index')
Run Code Online (Sandbox Code Playgroud)
这给我带来了这个错误:
You must pass a file to `app.import`. For directories specify them to the constructor under the `trees` option.Error: You must pass a file to `app.import`. For directories specify them to the constructor under the `trees` option.
at EmberApp.import (/home/jim/Desktop/TaskVelocity/task-velocity/node_modules/ember-cli/lib/broccoli/ember-app.js:521:11)
at Object.<anonymous> (/home/jim/Desktop/TaskVelocity/task-velocity/Brocfile.js:9:11)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
Run Code Online (Sandbox Code Playgroud)
为了让这个工作,我错过了什么?
尝试了用户的建议,并收到此错误:
Path or pattern "vendor/stripe/stripe.js" did not match any files Error: Path or pattern "vendor/stripe/stripe.js" did not match any files
at …Run Code Online (Sandbox Code Playgroud) 我正在使用
val akkaV = "2.2.3"
val sprayV = "1.2.0"
Seq(
"io.spray" % "spray-can" % sprayV,
"io.spray" % "spray-routing" % sprayV,
"io.spray" %% "spray-json" % "1.2.5",
"io.spray" % "spray-testkit" % sprayV,
"com.typesafe.akka" %% "akka-actor" % akkaV,
"com.typesafe.akka" %% "akka-testkit" % akkaV,
Run Code Online (Sandbox Code Playgroud)
并收到此错误:
找不到参数marshaller的隐含值:spray.httpx.marshalling.ToResponseMarshaller [List [org.bwi.models.Cluster]]
使用此代码:
object JsonImplicits extends DefaultJsonProtocol {
val impCluster = jsonFormat2(Cluster)
}
trait ToolsService extends HttpService with spray.httpx.SprayJsonSupport {
val myRoute = {
import JsonImplicits._
path("") { get { getFromResource("tools.html") } } ~
pathPrefix("css") { get { …Run Code Online (Sandbox Code Playgroud) 我有这个案例类定义:
class Protocol(protocol:String)
object Protocol {
def apply(protocol:String) :Protocol = {
protocol.toUpperCase match {
case "HTTP" => Http()
case "HTTPS" => Https()
case "Ftp" => Ftp()
case "Mail" =>Mail()
case other => new Protocol(other)
}
}
}
case class Http() extends Protocol("HTTP") {}
Run Code Online (Sandbox Code Playgroud)
然后我在这个案例类中使用它:
case class Url(protocol: Protocol,
username: Option[String],
password: Option[String],
domainName: DomainName,
port: Option[Int],
path: Option[List[String]],
parameters: Option[List[Parameter]]) {
Run Code Online (Sandbox Code Playgroud)
然后尝试在这里使用:
"An url class" should {
"represent http://localhost" in {
val url = Url(Http, None, None, localhost, None, None, …Run Code Online (Sandbox Code Playgroud) scala ×2
backbone.js ×1
bower ×1
broccolijs ×1
case-class ×1
ember-cli ×1
ember.js ×1
spray ×1
spray-json ×1