我有一个模板
<template name='order'>
{{vendor.name}}
</template>
Run Code Online (Sandbox Code Playgroud)
渲染
Template.order.vendor = function () {
return {name: 'Chanel', address: 'Paris' };
};
Run Code Online (Sandbox Code Playgroud)
当我尝试访问此数据时
Template.order.rendered = function () {
console.log(this.data);
};
Run Code Online (Sandbox Code Playgroud)
我得到'未定义'.
获得eg vendor.name和vendor.addressin 的正确方法是Template.order.rendered什么?
谢谢.
我正在尝试使用CasperJS登录Meteor应用程序.
以下是我的casper脚本的样子:
var casper = require('casper').create({
verbose: true,
logLevel: 'debug'
});
casper.start('http://localhost:3000/', function() {
this.test.assertTitle('app', 'App title is as expected');
this.test.assertExists('#login-sign-in-link', 'Sign in link exists');
this.capture('step-1.png');
this.click('a#login-sign-in-link');
this.test.assertExists('#login-email', 'Email field found');
this.test.assertExists('#login-password', 'Password field found');
this.capture('step-2.png');
this.evaluate(function (username, password) {
document.querySelector('#login-email').value = username;
document.querySelector('#login-password').value = password;
}, {
username: 'a@b.com',
password: 'testtest'
});
this.capture('step-3.png');
this.click('div#login-buttons-password');
this.test.assertExists("a#login-name-link","Signed in");
this.capture('step-4.png');
});
casper.run();
Run Code Online (Sandbox Code Playgroud)
结果如下:
ubuntu:~/tmp/casper$ casperjs test meteor-login.js
Test file: meteor-login.js
[info] [phantom] Starting...
[info] [phantom] Running suite: 2 steps
[debug] [phantom] opening …Run Code Online (Sandbox Code Playgroud)