Laravel Npm Node
发布时间:2018-11-20, 17:57:43 分类:PHP | 编辑 off 网址 | 辅助
图集1/1
正文 753字数 3,299,108阅读
[ Laravel 5.4 文档 ] 前端 —— 编译资源(Laravel Mix)
安装 Node
https://nodejs.org/en/download/
在开始接触 Mix 之前,必须首先确保 Node.js 和 NPM 在机器上已经安装:
node -v
npm -v
Run code
Cut to clipboard
Laravel Mix
接下来,需要安装 Laravel Mix,在新安装的 Laravel 根目录下,你会发现有一个 package.json 文件。该文件包含你所需要的一切,和 composer.json 类似,只不过是用来定义 Node 依赖而非 PHP 依赖,你可以通过运行如下命令来安装需要的依赖:
npm install
Run code
Cut to clipboard
如果你正在 Windows 系统上开发,需要在运行 npm install 命令时带上 --no-bin-links:
npm install --no-bin-links
Run code
Cut to clipboard
运行 Mix
Mix 是位于 Webpack 顶层的配置层,所以要运行 Mix 任务你只需要在运行包含在默认 package.json 文件中的其中某个 NPM 脚本即可:
// 运行所有 Mix 任务...
npm run dev
// 运行所有 Mix 任务并减少输出...
npm run production
Run code
Cut to clipboard
监控前端资源改变
npm run watch 命令将会持续在终端运行并监听所有相关文件的修改,Webpack将会在发现修改后自动重新编译资源文件:
npm run watch
Run code
Cut to clipboard
(支付宝)给作者钱财以资鼓励 (微信)→
有过 20 条评论 »
<?php function foo() { echo "In foo()<br />\n"; } function bar($arg = '') { echo "In bar(); argument was '$arg'.<br />\n"; } // 使用 echo 的包装函数 function echoit($string) { echo $string; } $func = 'foo'; $func(); // This calls foo() $func = 'bar'; $func('test'); // This calls bar() $func = 'echoit'; $func('test'); // This calls echoit()
<?php class Foo { function Variable() { $name = 'Bar'; $this->$name(); // This calls the Bar() method } function Bar() { echo "This is Bar"; } } $foo = new Foo(); $funcname = "Variable"; $foo->$funcname(); // This calls $foo->Variable()
当调用静态方法时,函数调用要比静态属性优先: Example #3 Variable 方法和静态属性示例 <?php class Foo { static $variable = 'static property'; static function Variable() { echo 'Method Variable called'; } } echo Foo::$variable; // This prints 'static property'. It does need a $variable in this scope. $variable = "Variable"; Foo::$variable(); // This calls $foo->Variable() reading $variable in this scope.
npm install cnpm -g -registry=https://registry.npm.taobao.org