namespace Facebook\WebDriver;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
require_once('vendor/autoload.php');
$host = 'http://localhost:4444/wd/hub';
$options = new ChromeOptions();
Run Code Online (Sandbox Code Playgroud)
我在创建类的对象时已阅读此链接,但ChromeOptions出现错误
PHP 致命错误:未捕获的错误:找不到类“Facebook\WebDriver\ChromeOptions”。
使用JSON.parse(JSON.stringify(obj))是我见过很多用于深度复制对象的老技巧。它是否创建了对象的真正“深层复制”?从性能角度来看,使用它是否明智?
我需要创建一个函数alphabetIndexer,它将一个字符串作为参数,并返回一个数字字符串,表示每个字母在字母表中的位置('a'为1,'z'为26).如果字符为大写,则将其位置乘以2.应忽略字符串中不是字母的所有字符.
function alphabetIndexer(str){
let alphabet = 'abcdefghigklmnopqrstuvwxyz';
let arr = [];
for(let i = 0; i < str.length; i++){
if(alphabet.includes(str[i].toLowerCase())){
if(str[i] === str[i].toUpperCase()){
arr.push(alphabet.indexOf((str[i] +1)*2))
} else {
arr.push(alphabet.indexOf(str[i]) +1);
}
}
}
return arr.join(' ');
}
Run Code Online (Sandbox Code Playgroud)
我不能让UpperCase字母位置乘以2;
在测试用例"Hello World"中它应该返回"16 5 12 12 15 46 15 17 12 4",但我的函数返回[-1,5,12,12,15,-1,15,18,12,4]
我有一个函数来评估一个元素(一个 iFrame)是否在视口内,如果该元素在视图中它返回 true。
function isElementInViewport() {
var el = document.getElementById('postbid_if')
var rect = el.getBoundingClientRect();
var elemTop = rect.top;
var elemBottom = rect.bottom;
console.log("eleTom " + elemTop)
console.log("elemBottom " + elemBottom)
console.log("window.innerHeight " + (window.innerHeight + (window.top.innerHeight * 0.5)))
var isVisible = (elemTop >= 0) && (elemBottom <= (window.innerHeight + window.innerHeight * 0.5));
return isVisible;
}
Run Code Online (Sandbox Code Playgroud)
当直接在页面上提供时,此函数可以正常工作,但在实时环境中,当此函数运行时,它位于 iFrame 内,并且看起来像是getBoundingClientRect()在引用 iFrame 的视口而不是主窗口?
有什么方法可以在 iFrame 中使用主窗口视口 getBoundingClientRect()
我试图将对象数组作为数据传递给图形数据,包括 x 的值和每个工具提示中使用的一些其他值。
在我的数据数组中,每个对象都包含x和value变量的值。我想访问value内部tooltips并最终显示当鼠标悬停在每个图形数据上时出现的工具提示内的值。
这是我的代码:
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: ['2017/06/12', '2017/06/23', '2017/07/12', '2017/07/23', '2017/08/12', '2017/08/23', '2017/09/12'],
datasets: [{
label: 'Values',
data: [{
y: 12,
value: 12
},
{
y: 3,
value: 13
},
{
y: 1,
value: 15
},
{
y: -3,
value: 5
},
{
y: 67,
value: 18
},
{
y: 12,
value: 11
},
{
y: 13,
value: 19
}
],
fill: …Run Code Online (Sandbox Code Playgroud) 我有一个像这样的 JSON 树结构。
[
{
"title":"News",
"id":"news"
},
{
"title":"Links",
"id":"links",
"children":[
{
"title":"World",
"id":"world",
"children":[
{
"title":"USA",
"id":"usa",
"children":[
{
"title":"Northeast",
"id":"northeast"
},
{
"title":"Midwest",
"id":"midwest"
}
]
},
{
"title":"Europe",
"id":"europe"
}
]
}
]
}
]
Run Code Online (Sandbox Code Playgroud)
我想要的是当我将“东北”传递给函数()时,它应该从根返回点符号字符串路径。在这种情况下,函数的预期返回字符串将是“links.world.usa.northeast”
我编写的这个 for-in 循环为所有对象属性打印“未定义”值:
let user = {
id: 1,
name: "Some name"
};
for (let prop in user)
console.log(prop + ": " + user.prop);Run Code Online (Sandbox Code Playgroud)
控制台输出:
id: undefined
name: undefined
Run Code Online (Sandbox Code Playgroud) 我有这些价值
['book_1', 'reader_2', 'book_borrower_3', 'book_reader_borrower_4']
Run Code Online (Sandbox Code Playgroud)
如何获得最后一个数字后面附加的数字_?我不能这样做str.split('_')[1],因为某些值确实具有2 _,我也可以使用slice获取最后一个字符,如果数字值大于1个字符该怎么办。
我有一个对象
{0: "item A", 1: "item B", 2: "item C"}
Run Code Online (Sandbox Code Playgroud)
如何将对象转换为这样的数组
[{0: "item A", 1: "item B", 2: "item C"}]
Run Code Online (Sandbox Code Playgroud)
现在我已经尝试过,Object.keys(obj)但它将对象中的每个元素返回到数组。
真的需要帮助。感谢您的帮助
我有 3 个模型“类别”、“帖子”和“用户”。Category 与 Post 具有 hasMany 关系。并且Post与User有belongsTo关系。
我有一个 Category 对象$cat1,我可以在我的视图中访问它的帖子(和 user_id),但我无法访问更多用户数据(行名称)
@foreach ($cat1->posts as $post)
{{ $post->title }}
{{ $post->user()->name }}
@endforeach
Run Code Online (Sandbox Code Playgroud)
这会引发错误
未定义的属性: Illuminate\Database\Eloquent\Relations\BelongsTo::$name
javascript ×8
json ×2
php ×2
chart.js ×1
cross-domain ×1
ecmascript-6 ×1
eloquent ×1
iframe ×1
laravel ×1
laravel-5 ×1
object ×1
parent-child ×1
selenium ×1
treeview ×1
typescript ×1