+
+ 用户名:{{user.username}}
+
+
\ No newline at end of file
diff --git a/client/templates/user_page.js b/client/templates/user_page.js
new file mode 100644
index 0000000..7f333d0
--- /dev/null
+++ b/client/templates/user_page.js
@@ -0,0 +1,9 @@
+Template.userPage.onRendered(function (){
+ this.subscribe("userById",Router.current().params._id)
+})
+
+Template.userPage.helpers({
+ user: function (){
+ return User.findOne(Router.current().params._id)
+ }
+})
\ No newline at end of file
diff --git a/lib/router.js b/lib/router.js
index 53b2ecd..4f6f857 100644
--- a/lib/router.js
+++ b/lib/router.js
@@ -1,5 +1,5 @@
import "/client/templates/loading.html"
-import "/client/templates/userPage.html"
+import "/client/templates/user_page.html"
import "/client/templates/not_found.html"
Router.configure({
@@ -11,17 +11,14 @@ Router.configure({
}
})
-Meteor.subscribe('user_res')
+// Meteor.subscribe('user_res')
Router.route("/")
Router.route("/nelson", {name: 'mainItem'})
Router.route("/user/:_id", {
- name: 'userPage',
- data(){
- return User.findOne(this.params._id)
- }
+ name: 'userPage'
})
Router.onBeforeAction('dataNotFound',{only: 'userPage'})
diff --git a/server/publication.js b/server/publication.js
index 5e899a9..f40b725 100644
--- a/server/publication.js
+++ b/server/publication.js
@@ -2,6 +2,10 @@ Meteor.publish("url_res",function () {
return UrlRes.find()
})
-Meteor.publish("user_res",function () {
- return User.find()
+// Meteor.publish("user_res",function () {
+// return User.find()
+// })
+
+Meteor.publish("userById",function (id) {
+ return User.find({_id:id})
})
\ No newline at end of file