我正在学习Javascript中面向对象编程的旅程.我从这里获得了这个视频版本http://www.objectplayground.com/我理解了相当多的原型方法而不是经典方法.
在观察内容时,我暂停了显示的经典方法与子类一起使用的示例,如下所示:
//superclass
function Answer(value){
this._val = value;
}
//define prototype property 'get' for the superclass
Answer.prototype.get = function fn1(){
return this._val;
}
//subclass
function FirmAnswer(value){
Answer.call(this,value);
}
FirmAnswer.prototype = Object.create(Answer.prototype);
FirmAnswer.prototype.constructor = FirmAnswer;
//define prototype property 'get' for subclass
FirmAnswer.prototype.get = function fn2(){
return Answer.prototype.get.call(this);
}
var luckAnswer = new FirmAnswer(7);
luckAnswer.get(); //7
Run Code Online (Sandbox Code Playgroud)
题:
从我的理解call函数,它将设置this当前上下文是例如从该行Answer.call(this,value)从FirmAnswer功能,所以_val从Answer会为设置FirmAnswer而不是为Answer(请纠正我,如果我错了).
因此,如果上述分析是正确的,那么它会导致我的混淆,为什么返回的get属性而不仅仅是因为已经设置为调用时?FirmAnswer.prototypeAnswer.prototype.get.call(this)Answer.prototype.get() …
javascript prototype-programming prototype-chain prototype-pattern
我们最近迁移到了Nginx,我们还需要从某个目录/路径(www.domain.com/images/test.jpg)中传输以下htaccess配置,其中该图像文件包含一个我们想要的php代码。跑。
AddHandler application/x-httpd-ea-php56 .jpg .png .gif
Run Code Online (Sandbox Code Playgroud)
做了一些研究并在下面找到了示例,但是由于我对配置nginx并不十分了解,所以我不确定为什么它不起作用。
第一:
location ~ \.(php|jpg)$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Run Code Online (Sandbox Code Playgroud)
第二:
location ~ .*\.php$ {
root /var/www/html/www.domain.com;
if (!-f $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1;
break;
}
include fastcgi_params;
#root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_intercept_errors off;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html/www.domain.com$fastcgi_script$
}
Run Code Online (Sandbox Code Playgroud)
我希望有人能帮助我。
更新08/09/2019-答案
location ~ ^/pathname/images/(.*)\.(jpg|png|gif)$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Run Code Online (Sandbox Code Playgroud)