我是Ruby的新手
MakModule.rb
module Display
class Multiply
def Multiply.mul(first, second)
return first * second
end
end
end
Run Code Online (Sandbox Code Playgroud)
MakRequire1.rb
require "Display"
puts Multiply.mul 5,6
Run Code Online (Sandbox Code Playgroud)
MakRequire2.rb
require "MakModule.rb"
puts Multiply.mul 5,6
Run Code Online (Sandbox Code Playgroud)
两个文件都给我下面的错误
ruby: No such file or directory -- makRequire (LoadError)
Run Code Online (Sandbox Code Playgroud)
我应该如何更正我的代码?
这是usex.pl:
#use strict;
require 'x.pl';
print $x;
Run Code Online (Sandbox Code Playgroud)
这是x.pl:
#use strict;
our $x = 99;
1;
Run Code Online (Sandbox Code Playgroud)
如图所示,它运行正常.如果我取消注释usex.pl中使用strict的行,我得到
Global symbol "$x" requires explicit package name
Run Code Online (Sandbox Code Playgroud)
在x.pl中使用或不使用strict似乎并不重要(除非我删除'our'关键字,但我对此不感兴趣.)
我是Perl的新手.为什么严格使$ x在主脚本中不可见,这是什么正常的解决方案?
我正在尝试在页面中包含一个文件.该文件位于名为phpThumb的文件夹中,该文件夹位于我的wordpress主题目录中.
这就是我试图包含文件的方式"
<?php require_once(get_bloginfo('template_url')."/phpThumb/phpThumb.config.php"); ?>
出于某种原因,这不起作用.
我检查并get_bloginfo() 返回一个值,但不回显值.
我三重检查了代码的有效性,这一切都很好IMO ...
什么可能是错的?
PS; 它工作正常,$_SERVER['DOCUMENT_ROOT']但它的输出依赖于当前页面(如果我错了,请纠正我)所以它对我来说效率不高.
我需要检查一个数字中的位数是否等于其他数字.我能想到的最好方法是:
require(Number.toString == """\d{8}""", throw new InvalidDateFormatException("Wrong format for string parameter"))
Run Code Online (Sandbox Code Playgroud)
所需的位数是8.有没有更好的方法?
根据/sf/answers/333835561/,我应该能够从.js文件中获取.coffee文件:
$ echo 'console.log "works"' > module.coffee
$ echo '
> require("coffee-script")
> require("./module")
> ' > test.js
$ node test.js
works
Run Code Online (Sandbox Code Playgroud)
但是,当我这样做时,我在运行test.js时收到此消息:
module.js:340
throw err;
^
Error: Cannot find module './module'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/jose/Desktop/pedo/test.js:2:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3
Run Code Online (Sandbox Code Playgroud)
我正在使用NVM安装Node 0.10.25.还使用使用NPM 1.3.24安装的CoffeeScript 1.7.1.
最简单的复制方法是通过Web上下文,通过执行以下操作:
创建一个file.php包含以下内容:<?php.没有空格!
请index.php使用以下内容:
<?php
header('Content-Type: text/plain');
require 'file.php';
echo 'test';
Run Code Online (Sandbox Code Playgroud)现在,见证结果.
预期: test
实际: <?phptest
在开发过程中我偶然发现了很多次,这很烦人.
环境:
为什么这样的行为,怎么来PHP不解析这个?
我正在用PHP编写一个未完全完成的代码.当我register.php在浏览器中打开这个脚本时,只有一个空白页面,因为我无法克服require('config.php').当我删除时,require('config.php')一切都会出现在我的浏览器中.
你能帮帮我,告诉我有什么问题require吗?
<?php
require('config.php');
if (isset($_POST['submit'])) {
} else {
$form = <<<EOT
<form action="register.php" method="POST">
First Name: <input type="text" name="name" /> <Br/>
Last Name: <input type="text" name="lname" /> <Br/>
Username: <input type="text" name="uname" /> <Br/>
Email: <input type="text" name="email1" /> <Br/>
Email2: <input type="text" name="email2" /> <Br/>
Pass: <input type="password" name="pass1" /> <Br/>
Pass2: <input type="password" name="pass2" /> <Br/>
<input type="submit" value="register" name="submit" />
</form>
EOT;
echo $form;
}
Run Code Online (Sandbox Code Playgroud) 我使用节点JS aplication并且我用模块创建了新的js文件.在这个模块中我只导出一个函数,在这个模块中我可以说我还有两个函数仅供内部使用,不应该暴露在外面,每个函数都使用不同的需要模块如下:
module.exports = function (app, express) {
var bodyParser = require('body-parser'),
url = require('url'),
http = require('http');
.....
};
function prRequest(req, res) {
httpProxy = require('http-proxy');
....
}
function postRequest(req, res) {
url = require('url');
....
}
Run Code Online (Sandbox Code Playgroud)
我的问题来自最佳实践,我应该在哪里提出要求(对于网址http等)
1.在所有需要它的功能中?在我的情况下内部和外部
2.globally在每个函数可以使用的文件中?
3.如果两个不行,我应该在哪里放置我应该在两个函数中使用的require URL?更好地放入函数或全局或者无关紧要
所以我用npm安装了vuejs:
"dependencies": {
"vue": "^2.5.2"
}
Run Code Online (Sandbox Code Playgroud)
我也在我的文件中导入它:
import "vue"
const app = new Vue({
el: "#app",
template: `
<div>
<h1>Siddharth Knows It All</h1>
</div>
`
});
Run Code Online (Sandbox Code Playgroud)
但是我面临的问题是,当我使用webpack编译代码并在本地服务器上运行它时,它会在控制台中输出Vue is not defined.
控制台也输出
您正在开发模式下运行Vue.确保在部署生产时打开生产模式.请访问https://vuejs.org/guide/deployment.html查看更多提示
谁能帮我?
我创建了一个模块,在其中我保留了调用api的函数.虽然'要求',但我得到以下错误:
./src/Components/Search/SearchPage.js
Module not found: Can't resolve '../utils/api' in 'C:\Users\riksch\Dropbox\projects\Current\greenmp\frontend\src\Components\Search'
Run Code Online (Sandbox Code Playgroud)
我的主要问题是:如何将api模块正确导入SearchPage.js?
这是我的项目的结构:
我突出显示了我使用的文件,1是我导入(需要)的文件,2是我尝试导入的模块.
这之前有用,但是现在我改变了文件夹结构,即使在调整路径之后,我也无法得到它.
我尝试了不同的导入路径,都有相同的错误.
SearchPage.js需要声明
const api = require('../utils/api')
Run Code Online (Sandbox Code Playgroud)
api.js
var axios = require('axios')
module.exports = {
retrievePlants: function(search_query, locale) {
console.log("api.retrievePlants executes")
console.log("url: " + 'http://127.0.0.1:8000/search/'+locale+'/'+search_query)
//FIXME: hardcoded URL HOST
// return axios.get('https://127.0.0.1/search/'+locale+'/'+search_query)
return axios.get('http://127.0.0.1:8000/search/'+locale+'/'+search_query)
.then(function(response) {
console.log("response.data:")
console.log(response.data)
return response.data
})
.catch(function(error) {
console.log("Error in Components.utils.api.retrievePlants:")
console.log(error)
console.log("console.log(error.response.data):")
console.log(error.response.data)
})
},
}
Run Code Online (Sandbox Code Playgroud) require ×10
javascript ×3
php ×3
include ×2
node.js ×2
coffeescript ×1
import ×1
importerror ×1
npm ×1
perl ×1
perl-module ×1
reactjs ×1
ruby ×1
scala ×1
strict ×1
vue.js ×1
wordpress ×1