0
我在我的應用程序中有一個功能來顯示客戶列表,然後編輯所有客戶的頁面。我得到的錯誤,當用戶重定向到編輯頁面 「預期模板或空,發現:未定義」預期的模板或null,找到:undefined
下面是我參考 Route.js
Router.route('/user/:userId', function() {
this.render('customeredit');
this.layout('mainNav');
});
HTML
<template name="customeredit">
{{#customerData}}
{{fname}}
{{/customerData}}
</template>
JS代碼
import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';
import '../templates/editUser.html';
import { Customers } from '../../imports/api/customers.js';
Template.customeredit.helpers({
customerData: function() {
var customerId = 'NpWkSWRpkQJKsNecG';
console.log(customerId);
console.log(Customers.findOne({_id: customerId}));
}
});
也請告訴我們如何從url中獲取用戶ID在m y以上的JS文件,因爲我生成的URL是:http://localhost:3000/user/NpWkSWRpkQJKsNecG,我需要在助手中獲取「NpWkSWRpkQJKsNecG」。