只是想了解它是如何工作的:
function say(something) {
return something;
}
let name = `Reza`;
console.log(say `My name is`, name, '!');Run Code Online (Sandbox Code Playgroud)
它返回一个非常奇怪的输出.我认为这My name is是一个数组中的字符串,其他一切只是一个字符串(如果我错了,请纠正我).
我的问题是,有什么意义,何时使用这样的函数是有意义的?
如果有人能告诉我为什么My name is ${name}不工作(name返回为空字符串),我也会很高兴.
PS:我知道可以使用带括号的函数,它可以工作,但这不是我的问题.
我想获得所有Wordpress插件的列表.
有一个函数被调用,get_plugins()但它将返回我已安装的所有插件.我需要的是所有插件的列表,无论我之前是否安装过它们.
有没有我可以使用的功能?如果没有,是否有JSON,数据库,API或我可以使用的任何东西?
编辑:
var_dump(plugins_api('query_plugins', array(
'per_page' => 100,
'tag' => 'contact form 7',
'number' => 5,
'page' => 1,
'fields' =>
array(
'short_description' => false,
'description' => false,
'sections' => false,
'tested' => false,
'requires' => false,
'rating' => false,
'ratings' => false,
'downloaded' => false,
'downloadlink' => false,
'last_updated' => false,
'added' => false,
'tags' => false,
'compatibility' => false,
'homepage' => false,
'versions' => false,
'donate_link' => false,
'reviews' => false,
'banners' => false,
'icons' …Run Code Online (Sandbox Code Playgroud) 我有一个简单的类,如下所示:
<?php
namespace App\Algorithm;
use App\Dao\MatchDao;
use App\Service\MatchService;
class Calculator {
private $users;
private $matchDao;
function __construct(MatchService $matchService, MatchDao $matchDao) {
$this->users = $matchService->users;
$this->matchDao = $matchDao;
}
public function hourlyRate() {
$query = $this->matchDao->getSingleColumn('Payment', 'hourly_rate', 32);
var_dump($query);
}
}
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误消息:
检测到服务“App\Algorithm\Calculator”的循环引用,路径:“App\Algorithm\Calculator -> App\Service\MatchService -> App\Algorithm\Calculator”。
匹配服务.php
<?php
namespace App\Service;
use App\Algorithm\Calculator;
use App\Algorithm\Collection;
class MatchService {
public $users;
private $collection;
private $calculator;
function __construct(Collection $collection, Calculator $calculator) {
$this->collection = $collection;
$this->calculator = $calculator;
}
public function getMatch($data) { …Run Code Online (Sandbox Code Playgroud) 在我的数据库我有柱id,uid和data我想排序id的DESC。
$this->getDoctrine()->getRepository(FormInputs::class)->findBy(['uid' => $uid], ['id', 'DESC']);
Run Code Online (Sandbox Code Playgroud)
如果我使用第二个参数 ( ['id', 'DESC']),则会出现以下错误:
为 App\Entity\FormInputs#0 指定的方向顺序无效
为什么我收到这个错误?
在我的文件中,var.sass我定义了变量$black. 我想在我的所有components.sass文件中使用该变量。为此,我需要写入@import每个文件还是有更好的解决方案来做到这一点?
我们都知道,components.sass当我将此类文件导入全局styles.sass文件时,我不能在内部使用这些变量。
我想运行一个函数,当选中复选框并停止该函数时,如果未选中该复选框.
这是我尝试的方式:
$('#auto').on('click', function() {
if ($(this).is(':checked')) {
// Interval
var autoInterval = window.setInterval(function() {
navi('next');
}, 1500);
}
else {
clearInterval(autoInterval);
}
});
Run Code Online (Sandbox Code Playgroud)
问题是clearInterval()不起作用,我没有错误.
https://jsfiddle.net/n339tzff/9/
如果我的代码看起来像这样:
// Interval
var autoInterval = window.setInterval(function() {
navi('next');
}, 1500);
// Auto Play
$('#auto').on('click', function() {
if ($(this).is(':checked')) {
autoInterval;
}
else {
clearInterval(autoInterval);
}
});
Run Code Online (Sandbox Code Playgroud)
但后来我又遇到了另一个问题......我只想navi('next')在单击复选框而不是在开头时运行该功能.