5

前端新手,想问问关于 import 命令执行的效率问题?

 8 months ago
source link: https://www.v2ex.com/t/969362
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

V2EX  ›  程序员

前端新手,想问问关于 import 命令执行的效率问题?

  kolibreathV · 1 小时 30 分钟前 · 785 次点击

之前没有写过前端,现在临时开始学习并且编码。简单学习了一下 Vue ,看了下项目代码和 vue.js 源码心中有些疑惑. 首先我先抛出一下我现在的理解,如果理解错误请大家指正下:

  1. vue.js 是一个很大的立刻执行函数,最后 return Vue 的构造函数。在vue._init()函数中会将 Vue 函数放到 window 上,这样全局都可以使用
  2. import 命令每次都会执行对应模块的代码

我看到在项目的很多地方都会 import Vue ,然后做Vue.use()等操作,那这样会不会因为 import 反复执行 vue.js?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK