窗口在nodejs

时间:2017-07-14 02:08:00

标签: javascript node.js laravel vue.js

我在laravel的资源代码中看到了一些代码,我对此并不完全了解。这些代码位于/sources/assets/js/app.js:

/**
 * First we will load all of this project's JavaScript dependencies which
 * includes Vue and other libraries. It is a great starting point when
 * building robust, powerful web applications using Vue and Laravel.
 */

require('./bootstrap');

window.Vue = require('vue');

我猜require()是节点require(),但我不知道窗口的来源,因为它不是nodejs对象。有人可以告诉我这些代码是什么?

1 个答案:

答案 0 :(得分:2)

代码在前端运行,因此我们可以将两个变量中的任何一个作为节点变量进行规则。

在Laravel的案例中,要求来自Browserify

“window”是客户端的JavaScript对象。通过分配window.Vue,他们将变量设置为全局变量,以便可以在前端的任何位置访问它。您可以阅读有关窗口变量here

的更多信息
相关问题