Should I use Meteor.startup() or $(function() {})

前端 未结 2 1461
悲&欢浪女
悲&欢浪女 2021-01-08 00:35

Do they do the same thing ?

Which one should I use inside client?

if ( Meteor.is_client ) {
    Meteor.startup(function () {
        // my code here
         


        
2条回答
  •  再見小時候
    2021-01-08 01:20

    As far as I can tell, Meteor.startup (on the client) is very similar to jQuery's $ function. The main advantage of using it is that it's the same API on client and server, so if you want to write startup code in files that are run on both client and server, Meteor.startup will just work. (Also, I personally find Meteor.startup to be easier to read and more self-documenting than $.)

提交回复
热议问题