{{log}}助手使輸出變量或表達(dá)式變得容易,其將輸出呈現(xiàn)到瀏覽器的控制臺(tái)。它也接受原始類型,如字符串或數(shù)字。
{{log 'Statment' VarName}}
<!DOCTYPE html> <html> <head> <title>Emberjs Development Helper Log</title> <!-- CDN's --> <script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/3.0.1/handlebars.min.js"></script> <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.10.0/ember.min.js"></script> <script src="https://builds.emberjs.com/tags/v1.10.0-beta.3/ember-template-compiler.js"></script> <script src="https://builds.emberjs.com/release/ember.debug.js"></script> <script src="https://builds.emberjs.com/beta/ember-data.js"></script> </head> <body> <script type="text/x-handlebars" data-template-name="index"> <!-- renders an output to the browser's console --> {{log 'Name is:' name}} </script> <script type="text/javascript"> App = Ember.Application.create(); App.IndexRoute = Ember.Route.extend({ setupController: function(controller){ controller.set('name', 'Tutorialspoint'); } }); </script> </body> </html>
上述程序的輸出將顯示在瀏覽器的控制臺(tái)中,如下圖所示。
更多建議: