问题
I am a Meteor newbie, and wonder if the following routing definitions transfer HTML between server and client, or manipulate page routing only in client side?
Meteor.Router.add({
'/news': 'news', // renders template 'news'
'/about': function() {
if (Session.get('aboutUs')) {
return 'aboutUs'; //renders template 'aboutUs'
} else {
return 'aboutThem'; //renders template 'aboutThem'
}
},
'*': 'not_found'
});
If it's the former, can I say that routing is not the "Meteor way" because of the first principles of Meteor is
Data on the Wire. Meteor doesn't send HTML over the network. The server sends data and lets the client render it.
回答1:
I am a Meteor newbie, and wonder if the following routing definitions transfer HTML between server and client, or manipulate page routing only in client side?
It's actually the latter that is correct, all the application views are transferred initially so client-side routing is just rendering the appropriate templates according to the current URL, no additionnal HTTP requests are performed to fetch server-side rendered HTML as it's the case in traditional LAMP (or any other SSR based stack) websites.
来源:https://stackoverflow.com/questions/27246524/does-routing-in-meteor-transfer-html-between-server-and-client