简体   繁体   中英

Mustache.js Javascript error when rendering variable

I have

var view = {
     firstName: 'John',
     lastName: 'Doe'
};

var output = Mustache.render("{{firstName}} {{lastName}}", view);

This gives an error

'undefined is not a function (evaluating 'c.attr("partial")')'

According to https://github.com/janl/mustache.js this is pretty much the same as their most basic example:

var view = {
  title: "Joe",
  calc: function () {
    return 2 + 4;
  }
};

var output = Mustache.render("{{title}} spends {{calc}}", view);

If that doesn't work you'll need to start back over in the docs. Are the relevant files/source-code being included correctly? Console errors? Using a conflicting system?

As written your code seems fine, so the problem is just "somewhere else" it seems.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM