require

Equivalent of requiring a subproperty in ES6 import

霸气de小男生 提交于 2019-12-02 00:35:27
I have an existing require : const {dialog} = require('electron').remote; I started using Babel for ES6, and would like to import this instead. So far I have: import electron from 'electron'; const {dialog} = electron.remote; This is ugly, and I can't help but feel there is a better way to do this. I just need the dialog here. How do I get at it in one line? ECMAScript module syntax doesn't allow deep destructuring. In fact it doesn't destructure at all. Import statements create live bindings between modules. Here is great blog post written by Ben Nadel. It should shed some light on bindings:

How to require_once from different directories?

ε祈祈猫儿з 提交于 2019-12-02 00:33:00
问题 I am trying to require my "library" files from php files in different folders, but it gives errors when trying to access them from a subfolder. For example I have such a directory: + home - file1.php ++ subfolder - file2.php ++ libraries - code_generator.php - database_library.php code_generator.php also depends on the other library: (LINE 25) require_once(realpath("./libraries/database_library.php")); //this works fine when called from file1.php, but not from file2.php I try to call code

测试一个requirejs的加载

六眼飞鱼酱① 提交于 2019-12-01 21:52:18
requirejs属性AMD规范,AMD即异步模块定义,它采用异步方式加载模块,不影响它后面的语句的执行。 优势 1.异步加载模块,不会阻碍页面的渲染 2.可保证加载顺序,可管理模块间的依赖,方便维护 3.可进行多人协同工作 必要的三个函数 define() 定义模块,响应require的调度 require.config() 设置模块与路径的映射 require() 程序的入口,包括两个参数,第一个为数组,表示依赖的模块;第二个参数为回调函数,它在当前页面指定的模块被加载完成才调用,加载的模块会以参数的形式传入该函数。 大专栏 测试一个requirejs的加载 kquote> demo 文件结构 requirejsDemo --index.html --js --clouse-2.js --main.js --requirejs.config.js --require.js 调试工具查看文件加载顺序 mian.js文件为入口文件 //加载配置文件 require(["js/requirejs.config"], function() { //加载clouse_2模块 require(["clouse_2"], function(clouse_2) { var btnModel = { name: "btnModel", click: function() { alert(this

How to require_once from different directories?

这一生的挚爱 提交于 2019-12-01 20:51:14
I am trying to require my "library" files from php files in different folders, but it gives errors when trying to access them from a subfolder. For example I have such a directory: + home - file1.php ++ subfolder - file2.php ++ libraries - code_generator.php - database_library.php code_generator.php also depends on the other library: (LINE 25) require_once(realpath("./libraries/database_library.php")); //this works fine when called from file1.php, but not from file2.php I try to call code_generator from ./subfolder/ file2.php like: chmod("../libraries/codegenerator.php", 0777); // for the

TypeScript require with type checking

半城伤御伤魂 提交于 2019-12-01 20:18:28
I am using TypeScript v1.4.1 and would like to require an external module (in this case "chai") and have it be type checked. However, I am running into some sort of naming conflict with this code: /// <reference path="../typings/node/node.d.ts" /> /// <reference path="../typings/chai/chai.d.ts" /> /// <reference path="../typings/mocha/mocha.d.ts" /> var chai = require("chai"); var expect = chai.expect; var assert = chai.assert; describe("TEST", () => { it("true should be true", (done)=> { expect(true).to.be.true; done(); }); }); With this definition file: declare module chai { ... } declare

使用laravel-wechat微信支付

混江龙づ霸主 提交于 2019-12-01 19:39:40
参考文档 https://github.com/overtrue/laravel-wechat https://easywechat.com/docs/4.1/payment/index laravel-wechat 微信 SDK for Laravel 5 / Lumen, 基于 overtrue/wechat 交流QQ群:319502940 框架要求 Laravel/Lumen >= 5.1 安装 # Laravel < 5.8 composer require "overtrue/laravel-wechat:~4.0" # Laravel >= 5.8 composer require "overtrue/laravel-wechat:~5.0" 配置 Laravel 应用 在 config/app.php 注册 ServiceProvider 和 Facade (Laravel 5.5 + 无需手动注册) 'providers' => [ // ... Overtrue\LaravelWeChat\ServiceProvider::class, ], 'aliases' => [ // ... 'EasyWeChat' => Overtrue\LaravelWeChat\Facade::class, ], 创建配置文件: php artisan vendor

测试一个requirejs的加载

陌路散爱 提交于 2019-12-01 18:42:47
requirejs属性AMD规范,AMD即异步模块定义,它采用异步方式加载模块,不影响它后面的语句的执行。 优势 1.异步加载模块,不会阻碍页面的渲染 2.可保证加载顺序,可管理模块间的依赖,方便维护 3.可进行多人协同工作 必要的三个函数 define() 定义模块,响应require的调度 require.config() 设置模块与路径的映射 require() 程序的入口,包括两个参数,第一个为数组,表示依赖的模块;第二个参数为回调函数,它在当前页面指定的模块被加载完成才调用,加载的模块会以参数的形式传入该函数。 大专栏 测试一个requirejs的加载 kquote> demo 文件结构 requirejsDemo --index.html --js --clouse-2.js --main.js --requirejs.config.js --require.js 调试工具查看文件加载顺序 mian.js文件为入口文件 //加载配置文件 require(["js/requirejs.config"], function() { //加载clouse_2模块 require(["clouse_2"], function(clouse_2) { var btnModel = { name: "btnModel", click: function() { alert(this

PHP数据展示之JpGraph类库

独自空忆成欢 提交于 2019-12-01 17:29:17
1. JpGraph 的介绍 1) jpgraph 是一种专门用于绘制统计图的运行库 , 使用 jpgraph 创建统计图时 , 只需要给出相应的数据 , 就能设置统计图标题和统计图类型即可 . 2) jpgraph 是一种面向对象的图像绘制库 , 既有 GD2 函数库 , 对其中函数进行封装 , 得到了几个用于生成统计图的函数 3) 可以生成 X-Y 坐标图 ,X-Y-Y 坐标图 , 柱形图 , 饼图 ,3D 饼图等统计图 , 并会自动生成坐标轴 , 坐标轴刻度 , 图例等信息 , 帮助我们快速生成所需样式 . 2. JpGraph 类库基本使用 2-1JpGraph 类库的安装和配置 下载地址 : https://jpgraph.net/download/ 只需要解压文件拷贝 src文件到项目文件夹即可使用 注意 :需要GD库支持 2-2JpGraph 类库的实例 2-2-1 创建 X-Y 坐标图 <?php //引入相关文件 require_once '../jpgraph/jpgraph-4.2.7/src/jpgraph.php' ; require_once '../jpgraph/jpgraph-4.2.7/src/jpgraph_line.php' ; //创建画布 $graph = new Graph ( 600 , 400 ) ; /* * 设置横纵坐标刻度样式

Node.js - require is not defined exception [closed]

一笑奈何 提交于 2019-12-01 16:22:34
I am a complete Node.js newbie and struggling with the basics. Running this code on the server: var http = require("http"), sys = require("util"), io = require("socket.io"), GlobTrie = require("glob-trie.js"); Gives me an exception at the first require: Uncaught ReferenceError: require is not defined (anonymous function) Any thoughts? Best regards, Ben. alessioalex Node.js is run on the server side, not on the browser side. Check out more about Node here: What is Node.js? Ben Case closed, I was including the wrong file on the client! Sorry to waste people time, but thanks for the Node links.

Brunch: separating vendor and app javascript

爷,独闯天下 提交于 2019-12-01 16:16:58
问题 I have made two bundles of javascript from our project- vendor and app. I do this in the manner suggested by the documentation, as seen in this snippet from my brunch-config.js: files: { javascripts: { joinTo: { 'js/vendor.js': /^(?!source\/)/, 'js/app.js': /^source\// }, entryPoints: { 'source/scripts/app.jsx': 'js/app.js' } } } And I end up with a vendor.js and an app.js. But check out the file sizes: Note how app.js is larger than vendor.js! This large size makes watching slower than it