Does routing in Meteor transfer HTML between server and client?

非 Y 不嫁゛ 提交于 2019-12-13 02:28:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!